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,86 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
@export var wallCheck: ShapeCast2D
@export var floorCheck: RayCast2D
@export var ledgeGrabBox: CollisionShape2D
const jumpGravity = player.GRAVITY
@onready var jumpHight = player.jumpHight
@onready var maxJumpCount = player.maxJumpCount
@onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed
@onready var friction = player.friction
var currentJumpCount: int
var coyoteJump: bool
@warning_ignore("unused_parameter")
func _physics_process(delta: float) -> void:
await player.move
if player.is_on_floor() or (player.is_on_wall() and GameInputEvents.wall_cling_input()):
currentJumpCount = 0
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
func on_phyisics_process(delta: float) -> void:
player.velocity.y += jumpGravity * delta
if player.is_on_floor():
currentJumpCount = 0
player.velocity.y = jumpHight
coyoteJump = false
currentJumpCount += 1
if coyoteJump and currentJumpCount != maxJumpCount:
player.velocity.y = jumpHight
coyoteJump = false
currentJumpCount += 1
#multi jumps
if !player.is_on_floor() and GameInputEvents.jump_input() and currentJumpCount != maxJumpCount:
player.velocity.y = jumpHight
currentJumpCount += 1
var direction: float = 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
if direction == 0:
player.velocity.x = move_toward(player.velocity.x, 0, friction * delta)
await player.move
transition_states()
func enter() -> void:
ledgeGrabBox.disabled = false
animatedSprite2D.play("Jump")
coyoteJump = true
func exit() -> void:
ledgeGrabBox.disabled = true
coyoteJump = false
animatedSprite2D.stop()
func transition_states() -> void:
#transition states
#idle state
if player.is_on_floor():
transition.emit("idle")
#fall state
if player.velocity.y > 0:
transition.emit("fall")
if wallCheck.is_colliding() and not floorCheck.is_colliding() and player.velocity.y == 0 and player.is_on_floor():
transition.emit("Grab")