Added wall states

This commit is contained in:
2026-06-28 19:59:18 +03:00
parent 204546b93a
commit 84ab412658
8 changed files with 136 additions and 6 deletions
@@ -13,6 +13,7 @@ enum Direction {
@export var another_direction : AbstractPlayerState
@export var run : AbstractPlayerState
@export var run_another_direction : AbstractPlayerState
@export var wall : AbstractPlayerState
func enter() -> void:
@@ -47,6 +48,8 @@ func physics_process(_delta: float) -> void:
switch_state.emit(run)
else:
switch_state.emit(run_another_direction)
elif player.is_on_wall():
switch_state.emit(wall)
else:
if not is_zero_approx(player.velocity.x):
match direction:
+40
View File
@@ -0,0 +1,40 @@
extends AbstractPlayerState
const PARTICLE_FACTOR = 100.0
enum Direction {
Left,
Right,
}
@export var direction := Direction.Left
@export var idle : AbstractPlayerState
@export var jump : AbstractPlayerState
@export var particles : GPUParticles2D
func enter() -> void:
particles.emitting = true
match direction:
Direction.Left:
player.player_sprite.play(ANIMATION_WALL_LEFT)
Direction.Right:
player.player_sprite.play(ANIMATION_WALL_RIGHT)
func exit() -> void:
particles.emitting = false
func physics_process(_delta: float) -> void:
particles.amount_ratio = clampf(player.velocity.y / PARTICLE_FACTOR, 0.0, 1.0)
if player.is_on_floor():
switch_state.emit(idle)
elif not player.is_on_wall():
switch_state.emit(jump)
@@ -0,0 +1 @@
uid://bghqpnc7vmmlh
@@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://ba5sknbijujl2"]
[ext_resource type="PackedScene" uid="uid://dqkewlpol05ap" path="res://game/entities/player/abstract_player_state.tscn" id="1_vvc6s"]
[ext_resource type="Script" uid="uid://bghqpnc7vmmlh" path="res://game/entities/player/states/wall_state.gd" id="2_kmlwa"]
[node name="WallState" unique_id=836520368 instance=ExtResource("1_vvc6s")]
script = ExtResource("2_kmlwa")