Skip to content

Commit

Permalink
fix: y-sort on winter theme
Browse files Browse the repository at this point in the history
Refactors the puzzle-scene to add players last (so they're on top of
dotted/dots anims), and enables y-sort on the winter dots/players. Could
have handled the ysort in the code.... but we'll see how different these
themes need to be first.
  • Loading branch information
russmatney committed Feb 22, 2024
1 parent 182b0d9 commit 0c3f41b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/puzzle/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ func _enter_tree():
## ready #########################################################

func _ready():
if z_index == 0:
z_index = 5

U.set_optional_nodes(self, {label="ObjectLabel", color_rect="ColorRect"})

render()

## render #########################################################
Expand Down
10 changes: 8 additions & 2 deletions src/puzzle/PuzzleScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ func rebuild_nodes():
if not Engine.is_editor_hint() and is_inside_tree():
ensure_camera()

var players = []
for y in len(state.grid):
for x in len(state.grid[y]):
var objs = state.grid[y][x]
Expand All @@ -340,11 +341,16 @@ func rebuild_nodes():
var node = create_node_at_coord(obj_name, coord)
if obj_name == "Player":
state.players.append(init_player(coord, node))
players.append(node)
else:
add_child(node)
if not coord in state.cell_nodes:
state.cell_nodes[coord] = []
state.cell_nodes[coord].append(node)

for p in players:
add_child(p)

if dhcam != null:
dhcam.center_on_rect(puzzle_rect({dots_only=true}))

Expand All @@ -361,9 +367,9 @@ func create_node_at_coord(obj_name:String, coord:Vector2) -> Node:
else:
node.position = coord * square_size
node.add_to_group("generated", true)
add_child(node)
if debugging or not Engine.is_editor_hint():
node.set_owner(self)
node.ready.connect(func():
node.set_owner(self))
return node

func node_for_object_name(obj_name):
Expand Down
3 changes: 3 additions & 0 deletions src/themes/dots/Dot.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ func render():
if anim != null:
match type:
DHData.dotType.Dot:
set_z_index(1)
anim.play("dot")
U.set_random_frame(anim)
DHData.dotType.Dotted:
set_z_index(0)
await get_tree().create_timer(0.4).timeout
if type == DHData.dotType.Dotted: # if we're still dotted
anim.play("dotted")
U.set_random_frame(anim)
DHData.dotType.Goal:
set_z_index(0)
anim.play("goal")
U.set_random_frame(anim)
2 changes: 2 additions & 0 deletions src/themes/winter/Dot.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ animations = [{
}]

[node name="Dot" type="Node2D"]
y_sort_enabled = true
script = ExtResource("1_jnnoi")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_qopwr")
animation = &"dot"
frame_progress = 0.743257
metadata/_aseprite_wizard_config_ = {
"layer": "",
"o_ex_p": "",
Expand Down
2 changes: 1 addition & 1 deletion src/themes/winter/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ animations = [{
}]

[node name="WinterPlayer" type="Node2D" groups=["player"]]
z_index = 5
y_sort_enabled = true
script = ExtResource("1_vvvex")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
Expand Down

0 comments on commit 0c3f41b

Please sign in to comment.