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,51 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
@export var collisionShapeMove: AnimationPlayer
@onready var friction = player.friction
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
@warning_ignore("unused_parameter")
func on_phyisics_process(delta: float) -> void:
player.velocity.x = move_toward(player.velocity.x, 0, friction * delta)
transition_states()
func enter() -> void:
collisionShapeMove.play("Crouch")
animatedSprite2D.play("Crouch")
func exit() -> void:
animatedSprite2D.stop()
func transition_states() -> void:
#transition states
#run state
var direction = GameInputEvents.movement_input()
if !player.is_on_floor():
collisionShapeMove.play("Normal")
transition.emit("fall")
if direction and player.is_on_floor():
transition.emit("crouchwalk")
#jump state
if GameInputEvents.jump_input():
collisionShapeMove.play("Normal")
transition.emit("jump")
#idle state
if not Input.is_action_pressed("crouch"):
collisionShapeMove.play("Normal")
transition.emit("idle")

View File

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

View File

@@ -0,0 +1,56 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
@export var collisionShapeMove: AnimationPlayer
const GRAVITY = player.GRAVITY
@onready var speed: float = player.speed /3
@onready var maxSpeed: float = player.maxSpeed /3
@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:
collisionShapeMove.play("Crouch")
animatedSprite2D.play("Crouch Walk")
func exit() -> void:
animatedSprite2D.stop()
func transition_states(direction) -> void:
#transition states
#fall state
if !player.is_on_floor():
collisionShapeMove.play("Normal")
transition.emit("fall")
#idle state
if direction == 0:
transition.emit("crouchidle")
#jump state
if GameInputEvents.jump_input():
collisionShapeMove.play("Normal")
transition.emit("jump")
if not Input.is_action_pressed("crouch"):
collisionShapeMove.play("Normal")
transition.emit("run")

View File

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

View File

@@ -0,0 +1,46 @@
extends NodeState
@export_category("nodes")
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
@export var ledgeGrabBox: CollisionShape2D
@export var wallCheck: ShapeCast2D
@export var floorCheck: RayCast2D
const GRAVITY = player.GRAVITY
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
@warning_ignore("unused_parameter")
func on_phyisics_process(delta: float) -> void:
var collision = wallCheck.get_collision_normal(0)
if collision.x == -1:
animatedSprite2D.flip_h = false
if collision.x == 1:
animatedSprite2D.flip_h = true
transition_states()
func enter() -> void:
player.velocity.x = 0
ledgeGrabBox.disabled = false
animatedSprite2D.play("Ledge Grab")
func exit() -> void:
ledgeGrabBox.disabled = true
animatedSprite2D.stop()
func transition_states() -> void:
if GameInputEvents.jump_input():
transition.emit("jump")
if floorCheck.is_colliding():
transition.emit("idle")
if GameInputEvents.crouch_input():
ledgeGrabBox.disabled = true
transition.emit("fall")

View File

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

View File

@@ -0,0 +1,44 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
@onready var friction = player.friction
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
@warning_ignore("unused_parameter")
func on_phyisics_process(delta: float) -> void:
player.velocity.x = move_toward(player.velocity.x, 0, friction * delta)
transition_states()
func enter() -> void:
animatedSprite2D.play("Idle")
func exit() -> void:
animatedSprite2D.stop()
func transition_states() -> void:
#transitioning state
#fall state
if !player.is_on_floor():
transition.emit("fall")
#run state
var direction: float = GameInputEvents.movement_input()
if direction and player.is_on_floor():
transition.emit("Run")
#jump state
if GameInputEvents.jump_input():
transition.emit("jump")
#shoot crouch state
if Input.is_action_pressed("crouch"):
transition.emit("CrouchIdle")

View File

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

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")

View File

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

View File

@@ -0,0 +1,21 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
@export var collisionShapeMove: AnimationPlayer
func enter() -> void:
collisionShapeMove.play("Crouch")
func on_phyisics_process(_delta: float) -> void:
transition_states()
func on_process(_delta: float) -> void:
pass
func exit() -> void:
collisionShapeMove.play("Normal")
func transition_states() -> void:
pass

View File

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