Snake/camera_2d.gd

42 lines
1,022 B
GDScript3
Raw Normal View History

2025-08-08 15:02:44 +10:00
extends Camera2D
#var target : Node2D
#@export var temp_segment : Node2D
2025-08-08 15:27:48 +10:00
@export var snake_line : Line2D
2025-08-08 15:02:44 +10:00
@export var player : Node2D
2025-08-08 15:02:44 +10:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
2025-09-03 12:14:08 +10:00
Router.die.connect(panic_zoomout)
2025-08-08 15:02:44 +10:00
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if Router.player_mode:
2025-08-08 15:17:37 +10:00
# TODO FIX
2025-08-08 15:27:48 +10:00
#position = lerp(position, target.position, 0.6 * delta)
#zoom = lerp(zoom, Vector2(1,1),0.6 * delta)
#position = Router.current_seg.position
position = player.global_position
2025-08-08 15:27:48 +10:00
zoom = Vector2(1,1)
snake_line.modulate = Color(1,1,1,1)
2025-08-08 15:27:48 +10:00
z_index = 0
snake_line.z_index = 9
2025-08-08 15:02:44 +10:00
else:
position = Vector2(0,0)
2025-08-15 13:33:08 +10:00
zoom = Vector2(0.1,0.1)
2025-08-08 15:27:48 +10:00
snake_line.modulate = Color(1,1,1,1)
snake_line.z_index = 11
2025-08-08 15:27:48 +10:00
z_index = 1
2025-09-03 12:14:08 +10:00
func panic_zoomout():
position = Vector2(0,0)
zoom = Vector2(0.1,0.1)
snake_line.modulate = Color(1,1,1,1)
snake_line.z_index = 11
z_index = 1