forked from OddlyTimbot/Sept26Game
week6 player enemy damage death cycle
This commit is contained in:
1 parent
c1bdb544a6
commit
ed7e5c4740
12 files changed
+306
-25
No files matched your search
+9
-1
@@ -14,7 +14,7 @@ var facing:FaceDirection = FaceDirection.RIGHT
|
||||
#direction 1 move to right, 0 no movement, -1 to the left
|
||||
var direction = 1
|
||||
|
||||
enum EnemyStates {RUN, ATTACK, SPAWN}
|
||||
enum EnemyStates {RUN, ATTACK, SPAWN, HURT}
|
||||
var currentEnemyState:EnemyStates = EnemyStates.SPAWN
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ func _process(delta: float) -> void:
|
||||
handleStates()
|
||||
handleAnimation()
|
||||
handleCollisions()
|
||||
|
||||
func takeDamage()->void:
|
||||
currentEnemyState = EnemyStates.HURT
|
||||
|
||||
func handleMovement(delta)->void:
|
||||
position.x += direction*speed*delta
|
||||
@@ -51,6 +54,9 @@ func handleAnimation()->void:
|
||||
slime_graphic.play("run")
|
||||
EnemyStates.ATTACK:
|
||||
slime_graphic.play("attack")
|
||||
EnemyStates.HURT:
|
||||
#swap for a hurt animation
|
||||
slime_graphic.play("attack")
|
||||
|
||||
func handleCollisions()->void:
|
||||
if not right_down_cast.is_colliding():
|
||||
@@ -84,3 +90,5 @@ func _on_animation_finished() -> void:
|
||||
EnemyStates.ATTACK:
|
||||
currentEnemyState = EnemyStates.RUN
|
||||
direction = (randi() % 2) *2 -1
|
||||
EnemyStates.HURT:
|
||||
currentEnemyState = EnemyStates.RUN
|
||||
Reference in new issue
Block a user