Added player and a basic test level

This commit is contained in:
2026-02-06 16:00:03 -05:00
parent 1b0f1c9080
commit 83a4a8f374
104 changed files with 6897 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
const GRAVITY = player.GRAVITY
@onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
func on_phyisics_process(delta: float) -> void:
var direction = GameInputEvents.movement_input()
if direction:
player.velocity.x += direction * speed * delta
player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed)
if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true
transition_states(direction)
func enter() -> void:
animatedSprite2D.play("Run")
func exit() -> void:
animatedSprite2D.stop()
func transition_states(direction) -> void:
#transition states
#fall state
if !player.is_on_floor():
transition.emit("fall")
#idle state
if direction == 0:
transition.emit("idle")
#jump state
if GameInputEvents.jump_input():
transition.emit("jump")
#Crouch state
#TODO make work better
if GameInputEvents.crouch_input():
transition.emit("crouchwalk")