adding a charge attack to states

This commit is contained in:
OddlyTimbot committed 2026-07-06 14:32:07 -04:00
1 parent 29b125f5af
commit 2dd2c13b19
6 files changed
+110 -4

No files matched your search

+16 -2
View File
@@ -19,7 +19,7 @@ const JUMP_VELOCITY = -400.0
enum FaceDirection {RIGHT,LEFT}
var facing:FaceDirection = FaceDirection.RIGHT
#State Handling
enum PlayerState {IDLE, RUNNING, JUMPING, FALLING}
enum PlayerState {IDLE, RUNNING, JUMPING, FALLING, CHARGING, SHOVING}
var current_player_state:PlayerState = PlayerState.IDLE
var upJump:bool = false
@@ -43,15 +43,23 @@ func handle_input()->void:
# Handle shove.
if Input.is_action_just_pressed("shove"):
print("I want to shove")
pushTimer = Time.get_ticks_msec()
if pushRightEnabled and facing==FaceDirection.RIGHT:
pushTimer = Time.get_ticks_msec()
current_player_state = PlayerState.CHARGING
if pushLeftEnabled and facing==FaceDirection.LEFT:
pushTimer = Time.get_ticks_msec()
current_player_state = PlayerState.CHARGING
if Input.is_action_just_released("shove"):
var pushForce = Time.get_ticks_msec() - pushTimer
if pushForce>4000:
pushForce=4000
if pushRightEnabled and facing==FaceDirection.RIGHT:
#deliver the boom
current_player_state=PlayerState.SHOVING
pushSignal.emit(pushTarget, Vector2(1,0)*100*(pushForce/100))
if pushLeftEnabled and facing==FaceDirection.LEFT:
current_player_state=PlayerState.SHOVING
pushSignal.emit(pushTarget, Vector2(-1,0)*100*(pushForce/100))
#Handle Shoot Bullet
if Input.is_action_just_pressed("shoot"):
@@ -140,9 +148,15 @@ func handle_update_animation()->void:
player_graphic.play("jumping")
PlayerState.FALLING:
player_graphic.play("falling")
PlayerState.CHARGING:
player_graphic.play("charging")
PlayerState.SHOVING:
player_graphic.play("shoving")
func _on_animation_finished() -> void:
match current_player_state:
PlayerState.JUMPING:
upJump = false
PlayerState.SHOVING:
current_player_state = PlayerState.IDLE
+1 -1
View File
@@ -58,7 +58,7 @@ func stash(bullet:Bullet)->void:
func destroy(body)->void:
match body:
var bod when bod is Rocket:
print("removing rocket")
body.queue_free()
var bod when bod is Crate:
body.queue_free()
var bod when bod is Bullet: