summaryrefslogtreecommitdiffstats
path: root/ps_dead.gd
blob: b042a8d384f36a3e9c3f0b5894be14411617e580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class_name PlayerStateDead
extends PlayerState

const DEAD_TIMEOUT = 1 # sec

func _to_string() -> String:
	return "PlayerStateDead"

func _init(pl: Player):
	super(pl)

	p.anim_sp.set_animation("dead")
	p.request_play_die_sfx()

	wait_respawn.call_deferred()
	
func wait_respawn():
	await p.get_tree().create_timer(DEAD_TIMEOUT).timeout
	p.top.game_load()

func _handle(_delta: float):
	pass

func _handle_physics(delta: float):
	p.velocity.y += p.gravity * delta
	if p.velocity.y > p.jump_strength:
		p.velocity.y = p.jump_strength
	
	p.velocity.x = 0

	p.move_and_slide()