diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-06-05 09:18:35 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-06-05 09:18:35 -0600 |
commit | 4b42a8ba26f21e2c6c766fa747c8b93a115a53b2 (patch) | |
tree | a688e3be103942c1a1057b65ca61ea26f57dd5ee /src/entities/actors/snake/scripts/normal_state.gd | |
parent | e4423cc8490b7f5ec3449f568bf64e81f4d03248 (diff) |
added new tiles to ground tilemap, moved player to state machine paradigm
Diffstat (limited to 'src/entities/actors/snake/scripts/normal_state.gd')
-rw-r--r-- | src/entities/actors/snake/scripts/normal_state.gd | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/entities/actors/snake/scripts/normal_state.gd b/src/entities/actors/snake/scripts/normal_state.gd new file mode 100644 index 0000000..11981a3 --- /dev/null +++ b/src/entities/actors/snake/scripts/normal_state.gd @@ -0,0 +1,28 @@ +extends Node + +var fsm: StateMachine + + +func enter(): + if fsm.DEBUG: + print("Got inside %s." % name) + + +func exit(next_state): + fsm.change_to(next_state) + + +func physics_process(delta: float) -> void: + fsm.player.velocity = fsm.player.direction * Global.SNAKE_SPEED + fsm.player.velocity = fsm.player.move_and_slide(fsm.player.velocity) + + fsm.slow_down_on_collisions(Global.SNAKE_SPEED_BACKUP) + + +func input(event: InputEvent) -> void: + if fsm.player.can_dash and event.is_action_pressed("dash"): + exit("DashState") + if fsm.player.can_slow and event.is_action_pressed("slow"): + exit("SlowState") + # if fsm.player.can_jump and event.is_action_pressed("jump"): + # exit("JumpState") |