feat: cameras
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 2m9s

This commit is contained in:
2025-07-31 18:26:01 +02:00
parent 503efeb5ec
commit 797438d0fd
8 changed files with 12923 additions and 5 deletions

39
camera/camera.gd Normal file
View File

@ -0,0 +1,39 @@
extends Node2D
@onready var area_2d: Area2D = $Area2D
@onready var camera: Camera2D = $Camera2D
@export var should_follow_player = false
@export var minimum_location = 0
@export var maximum_location = 640
var is_player_in_range = false
var player: Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if not should_follow_player or not is_player_in_range:
return
if player.global_position.x < minimum_location or player.global_position.x > maximum_location:
return
global_position.x = player.global_position.x
func _on_body_entered(body: Node2D) -> void:
if body.name == "Player":
camera.make_current()
player = body
is_player_in_range = true
func _on_body_exited(body: Node2D) -> void:
if body.name == "Player":
is_player_in_range = false

1
camera/camera.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://cn0crfbdlcoot