camera, textures, scaling, tilemap

This commit is contained in:
torontocaper committed 2026-05-11 21:03:27 -04:00
1 parent e80ace000d
commit 28b59ef4fe
19 files changed
+661 -12

No files matched your search

+25 -3
View File
@@ -5,8 +5,9 @@ const JUMP_VELOCITY = -500.0
var direction
enum FaceDirection{LEFT, RIGHT}
var facing:FaceDirection = FaceDirection.RIGHT
enum player_state{IDLE,RUNNING}
enum player_state{IDLE,RUNNING,JUMPING,FALLING}
var current_player_state:player_state = player_state.IDLE
var upJump:bool = false
@onready var player_graphic: AnimatedSprite2D = $"player graphic"
@@ -46,8 +47,12 @@ func handle_input()->void:
shoveDirection = -1
pushTarget.apply_central_impulse(Vector2(shoveDirection,0)*700)
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
upJump = true
current_player_state = player_state.JUMPING
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
direction = Input.get_axis("ui_left", "ui_right")
if direction<0:
facing = FaceDirection.LEFT
@@ -55,6 +60,8 @@ func handle_input()->void:
if direction>0:
facing = FaceDirection.RIGHT
player_graphic.flip_h = false
func handle_movement(delta)->void:
if not is_on_floor():
@@ -90,6 +97,11 @@ func handle_state()->void:
current_player_state = player_state.RUNNING
player_state.RUNNING when velocity.x ==0:
current_player_state = player_state.IDLE
player_state.JUMPING when velocity.y >0:
current_player_state = player_state.FALLING
player_state.FALLING when is_on_floor():
current_player_state = player_state.IDLE
func handle_animation()->void:
match current_player_state:
@@ -97,3 +109,13 @@ func handle_animation()->void:
player_graphic.play("idle")
player_state.RUNNING:
player_graphic.play("run")
player_state.JUMPING:
if upJump:
player_graphic.play("jump")
player_state.FALLING:
player_graphic.play("fall")
func _on_animation_finished() -> void:
match current_player_state:
player_state.JUMPING:
upJump = false