You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
704 B
GDScript
33 lines
704 B
GDScript
3 years ago
|
extends Actor
|
||
3 years ago
|
|
||
3 years ago
|
enum PlayerState { NORMAL = 0, # < default from Actor
|
||
|
DASHING = 1,
|
||
|
STANDING = 2,
|
||
|
ATTACKING = 3 };
|
||
3 years ago
|
|
||
|
var screen_size # Size of the game window.
|
||
|
var last_process_velocity = Vector2()
|
||
|
|
||
3 years ago
|
var key_map
|
||
|
|
||
3 years ago
|
func start(pos):
|
||
|
position = pos
|
||
3 years ago
|
state_map = {PlayerState.NORMAL: PlayerNormal.new(),
|
||
|
PlayerState.ATTACKING: PlayerAttack.new()}
|
||
3 years ago
|
|
||
|
var ak = AttackKey.new()
|
||
|
key_map = { KEY_Z: ak.register(self) }
|
||
3 years ago
|
show()
|
||
|
|
||
|
func _process(delta):
|
||
3 years ago
|
state_map[state].run(self, delta)
|
||
3 years ago
|
|
||
3 years ago
|
func _ready():
|
||
|
screen_size = get_viewport_rect().size
|
||
3 years ago
|
|
||
|
func _on_AnimatedSprite_animation_finished():
|
||
3 years ago
|
state_map[state].spriteFinished(self)
|
||
|
|
||
|
func getAnimatedSprite():
|
||
|
return $AnimatedSprite
|