create player state class

This commit is contained in:
yuki 2025-11-14 16:17:48 -03:00
parent 13ae274106
commit 37d5fa981d
4 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,32 @@
class_name PlayerState extends State
const IDLE = "Idle"
const RUNNING = "Running"
const HITTING = "Hitting"
var player: Player
func _ready() -> void:
await owner.ready
player = owner as Player
assert(player != null, "The PlayerState state type must be used only in the player scene. It needs the owner to be a Player node.")
func enter(previous_state_path: String, data: Dictionary = {}) -> void:
pass
func exit() -> void:
pass
func handle_input(_event: InputEvent) -> void:
pass
func state_update(_delta: float) -> void:
pass
func state_physics_update(_delta: float) -> void:
pass

View file

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

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://delu380dsl2kl"]
[ext_resource type="Script" uid="uid://b2sr7p80gdjii" path="res://scenes/classes/player_state.gd" id="1_opnr7"]
[node name="PlayerState" type="Node"]
script = ExtResource("1_opnr7")

View file

@ -1,4 +1,4 @@
extends CharacterBody2D
class_name Player extends CharacterBody2D
@export var id: int = 1
@export var max_speed: float = 90