fin~ player damage, player death, slime damag,e slime death, custom resources. multiple levels
This commit is contained in:
1 parent
c1bdb544a6
commit
7ead578152
19 files changed
+1383
-21
No files matched your search
+21
-3
@@ -11,10 +11,11 @@ class_name Player extends CharacterBody2D
|
||||
|
||||
var direction
|
||||
signal bulletSignal(pos, speed)
|
||||
signal deathCompleteSignal
|
||||
|
||||
enum FaceDirection {LEFT,RIGHT}
|
||||
var facing:FaceDirection = FaceDirection.RIGHT
|
||||
enum PlayerStates {IDLE,RUNNING,JUMPING,FALLING}
|
||||
enum PlayerStates {IDLE,RUNNING,JUMPING,FALLING,HURT,DEATH}
|
||||
var current_player_state:PlayerStates = PlayerStates.IDLE
|
||||
var upJump:bool = false
|
||||
|
||||
@@ -31,8 +32,9 @@ func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
handle_input()
|
||||
|
||||
if not current_player_state == PlayerStates.DEATH:
|
||||
handle_input()
|
||||
handle_movement()
|
||||
handle_states()
|
||||
handle_animations()
|
||||
@@ -133,9 +135,25 @@ func handle_animations()->void:
|
||||
player_graphic.play("jump")
|
||||
PlayerStates.FALLING:
|
||||
player_graphic.play("fall")
|
||||
PlayerStates.HURT:
|
||||
player_graphic.play("hurt")
|
||||
PlayerStates.DEATH:
|
||||
player_graphic.play("death")
|
||||
|
||||
|
||||
func _animation_finished() -> void:
|
||||
match current_player_state:
|
||||
PlayerStates.JUMPING:
|
||||
upJump = false
|
||||
PlayerStates.HURT:
|
||||
current_player_state = PlayerStates.IDLE
|
||||
PlayerStates.DEATH:
|
||||
deathCompleteSignal.emit()
|
||||
|
||||
func takeDamage()->void:
|
||||
print("player taking damage")
|
||||
current_player_state = PlayerStates.HURT
|
||||
|
||||
func kill()->void:
|
||||
print("kill the player")
|
||||
current_player_state = PlayerStates.DEATH
|
||||
Reference in new issue
Block a user