Merge branch 'main' of https://gitlab.com/PennyRigate/hero-mark-2
This commit is contained in:
commit
49fd274302
7 changed files with 167 additions and 12 deletions
|
@ -12,7 +12,7 @@ onready var dust_particles = $DustParticles
|
|||
#Map
|
||||
onready var map = get_owner()
|
||||
##States
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT}
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE}
|
||||
var current_state = State.IDLE
|
||||
##Runtime
|
||||
var axis = Vector2.ZERO #Current direction being held
|
||||
|
@ -41,6 +41,8 @@ func _physics_process(delta):
|
|||
#Check ladder
|
||||
check_ladder()
|
||||
match current_state:
|
||||
State.INACTIVE:
|
||||
return
|
||||
State.IDLE:
|
||||
_process_idle()
|
||||
continue
|
||||
|
@ -69,7 +71,8 @@ func _physics_process(delta):
|
|||
_process_shoot()
|
||||
|
||||
#Gravity
|
||||
if current_state != State.CLIMB: velocity.y += gravity
|
||||
if current_state != State.CLIMB:
|
||||
velocity.y += gravity
|
||||
#Cut y velocity when hitting ceiling
|
||||
if is_on_ceiling():
|
||||
current_state = State.FALL
|
||||
|
@ -251,14 +254,25 @@ func die():
|
|||
new_particles.global_position = global_position
|
||||
new_particles.emitting = true
|
||||
sprite.visible = false
|
||||
Game.play_sound(Game.a_die,Game.ac_die)
|
||||
yield(Game.freeze_frame(0.3), "timeout")
|
||||
position = Game.respawn_point
|
||||
sprite.visible = true
|
||||
current_state = State.IDLE
|
||||
Game.lives -= 1
|
||||
if Game.lives < 0:
|
||||
new_particles.amount = 64
|
||||
new_particles.lifetime = 0.45
|
||||
new_particles.speed_scale = 1.5
|
||||
current_state = State.INACTIVE
|
||||
Game.play_sound(Game.a_gover, Game.ac_die)
|
||||
var time_tween = get_tree().create_tween()
|
||||
time_tween.tween_property(Engine, "time_scale", 0.1, 0.3)
|
||||
Game.ac_music.stop()
|
||||
yield(time_tween, "finished")
|
||||
yield(get_tree().create_timer(1.0 * 0.1), "timeout")
|
||||
Game.call_deferred("restart_level")
|
||||
else:
|
||||
Game.play_sound(Game.a_die, Game.ac_die)
|
||||
yield(Game.freeze_frame(0.3), "timeout")
|
||||
position = Game.respawn_point
|
||||
current_state = State.IDLE
|
||||
sprite.visible = true
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
#Return to idle after slash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue