Skip to content

Commit

Permalink
feat: dynamically drop camera follow nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Jan 16, 2024
1 parent 1c7f435 commit 34dcdb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/PuzzlePhantomCamera.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@

[sub_resource type="Resource" id="Resource_romtu"]
script = ExtResource("2_ddwqt")
duration = 0.6
transition = 1
ease = 2
duration = 0.4
transition = 4
ease = 0

[node name="PhantomCamera2D" type="Node2D"]
script = ExtResource("1_mclm1")
priority_override = false
priority = 0
zoom = Vector2(4, 4)
zoom = Vector2(1, 1)
follow_mode = 3
follow_group = Array[NodePath]([])
follow_parameters/auto_zoom = false
follow_parameters/auto_zoom = true
follow_parameters/min_zoom = 2.0
follow_parameters/max_zoom = 4.0
follow_parameters/zoom_margin = Vector4(10, 10, 10, 10)
follow_parameters/target_offset = Vector2(0, 0)
follow_parameters/damping = false
follow_parameters/damping = true
follow_parameters/damping_value = 10.0
frame_preview = true
pixel_perfect = true
limit/draw_limits = true
Expand Down
8 changes: 8 additions & 0 deletions src/puzzle/DotHopPuzzle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ func rebuild_nodes():

if pcam != null:
pcam.append_follow_group_node_array(all_cell_nodes())
for p in state.players:
pcam.append_follow_group_node(p.node)

# trigger HUD update
rebuilt_nodes.emit()
Expand Down Expand Up @@ -432,6 +434,9 @@ func mark_cell_dotted(cell):
state.grid[cell.coord.y][cell.coord.x].erase("Dot")
state.grid[cell.coord.y][cell.coord.x].append("Dotted")

if pcam != null:
pcam.erase_follow_group_node(node)

# converts dotted back to dot (undo)
# depends on cell for `coord` and `nodes`.
func mark_cell_undotted(cell):
Expand All @@ -451,6 +456,9 @@ func mark_cell_undotted(cell):
state.grid[cell.coord.y][cell.coord.x].erase("Dotted")
state.grid[cell.coord.y][cell.coord.x].append("Dot")

if pcam != null:
pcam.append_follow_group_node(node)

## move to dot ##############################################################

func move_to_dot(player, cell):
Expand Down

0 comments on commit 34dcdb4

Please sign in to comment.