Skip to content

Commit 2df3169

Browse files
committed
Rename allowLeftToRight attribute, add placement options
1 parent ee13b39 commit 2df3169

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

Ahorn/entities/sidewaysJumpThru.jl

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,29 @@ module SpringCollab2020SidewaysJumpThru
33
using ..Ahorn, Maple
44

55
@mapdef Entity "SpringCollab2020/SidewaysJumpThru" SidewaysJumpThru(x::Integer, y::Integer, height::Integer=Maple.defaultBlockHeight,
6-
allowLeftToRight::Bool=true, texture::String="wood")
6+
left::Bool=true, texture::String="wood")
77

88
textures = ["wood", "dream", "temple", "templeB", "cliffside", "reflection", "core", "moon"]
9-
const placements = Ahorn.PlacementDict(
10-
"Sideways Jump Through ($(uppercasefirst(texture))) (Spring Collab 2020)" => Ahorn.EntityPlacement(
9+
const placements = Ahorn.PlacementDict()
10+
11+
for texture in textures
12+
placements["Sideways Jump Through ($(uppercasefirst(texture)), Left) (Spring Collab 2020)"] = Ahorn.EntityPlacement(
1113
SidewaysJumpThru,
1214
"rectangle",
1315
Dict{String, Any}(
14-
"texture" => texture
16+
"texture" => texture,
17+
"left" => true
1518
)
16-
) for texture in textures
17-
)
19+
)
20+
placements["Sideways Jump Through ($(uppercasefirst(texture)), Right) (Spring Collab 2020)"] = Ahorn.EntityPlacement(
21+
SidewaysJumpThru,
22+
"rectangle",
23+
Dict{String, Any}(
24+
"texture" => texture,
25+
"left" => false
26+
)
27+
)
28+
end
1829

1930
quads = Tuple{Integer, Integer, Integer, Integer}[
2031
(0, 0, 8, 7) (8, 0, 8, 7) (16, 0, 8, 7);
@@ -44,19 +55,19 @@ function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::SidewaysJumpThru, r
4455
y = Int(get(entity.data, "y", 0))
4556

4657
height = Int(get(entity.data, "height", 8))
47-
allowLeftToRight = get(entity.data, "allowLeftToRight", true)
48-
58+
left = get(entity.data, "left", true)
59+
4960
startX = div(x, 8) + 1
5061
startY = div(y, 8) + 1
5162
stopY = startY + div(height, 8) - 1
5263

5364
Ahorn.Cairo.save(ctx)
5465

5566
Ahorn.rotate(ctx, pi / 2)
56-
57-
if !allowLeftToRight
58-
Ahorn.scale(ctx, 1, -1)
59-
end
67+
68+
if left
69+
Ahorn.scale(ctx, 1, -1)
70+
end
6071

6172
len = stopY - startY
6273
for i in 0:len
@@ -72,7 +83,7 @@ function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::SidewaysJumpThru, r
7283
end
7384

7485
quad = quads[2 - connected, qx]
75-
Ahorn.drawImage(ctx, "objects/jumpthru/$(texture)", 8 * i, allowLeftToRight ? -8 : 0, quad...)
86+
Ahorn.drawImage(ctx, "objects/jumpthru/$(texture)", 8 * i, left ? 0 : -8, quad...)
7687
end
7788

7889
Ahorn.Cairo.restore(ctx)

Ahorn/lang/en_gb.lang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ placements.entities.SpringCollab2020/UpsideDownJumpThru.tooltips.texture=Changes
4747

4848
# Sideways Jump Thru
4949
placements.entities.SpringCollab2020/SidewaysJumpThru.tooltips.texture=Changes the appearance of the platform.
50-
placements.entities.SpringCollab2020/SidewaysJumpThru.tooltips.allowLeftToRight=Changes the orientation of the platform. If checked, it will allow the player to go from left to right.
50+
placements.entities.SpringCollab2020/SidewaysJumpThru.tooltips.left=Whether the solid side of the jumpthru is the left side.

Entities/SidewaysJumpThru.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ private static int onPlayerNormalUpdate(On.Celeste.Player.orig_NormalUpdate orig
220220
return result;
221221
}
222222

223-
224-
223+
// ======== Begin of entity code ========
225224

226225
private int lines;
227226
private string overrideTexture;
@@ -244,7 +243,7 @@ public SidewaysJumpThru(Vector2 position, int height, bool allowLeftToRight, str
244243
}
245244

246245
public SidewaysJumpThru(EntityData data, Vector2 offset)
247-
: this(data.Position + offset, data.Height, data.Bool("allowLeftToRight"), data.Attr("texture", "default")) {
246+
: this(data.Position + offset, data.Height, !data.Bool("left"), data.Attr("texture", "default")) {
248247
}
249248

250249
public override void Awake(Scene scene) {

0 commit comments

Comments
 (0)