Added level mods and updated sprite imports
This commit is contained in:
+10
-5
@@ -9,8 +9,10 @@ export var FRICTION := 2000
|
||||
var player_velocity = Vector2.ZERO
|
||||
var state = State.IDLE
|
||||
var follower : KinematicBody2D
|
||||
var leader := self
|
||||
|
||||
onready var sprite := $AnimatedSprite
|
||||
onready var chevron_sprite := $ChevronSprite
|
||||
|
||||
enum State {
|
||||
MOVE,
|
||||
@@ -21,11 +23,14 @@ enum State {
|
||||
func _physics_process(delta: float) -> void:
|
||||
match state:
|
||||
State.MOVE:
|
||||
move_state(delta)
|
||||
_move_state(delta)
|
||||
State.IDLE:
|
||||
idle_state(delta)
|
||||
|
||||
func move_state(delta: float) -> void:
|
||||
_idle_state(delta)
|
||||
chevron_sprite.visible = follower != null
|
||||
if follower != null:
|
||||
chevron_sprite.rotation_degrees = rad2deg((follower.house_position - global_position).angle()) - 90
|
||||
|
||||
func _move_state(delta: float) -> void:
|
||||
var input_vector := Vector2.ZERO
|
||||
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
|
||||
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
|
||||
@@ -47,7 +52,7 @@ func move_state(delta: float) -> void:
|
||||
if player_velocity == Vector2.ZERO:
|
||||
state = State.IDLE
|
||||
|
||||
func idle_state(delta: float) -> void:
|
||||
func _idle_state(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("ui_up") or Input.is_action_just_pressed("ui_down") or Input.is_action_just_pressed("ui_left") or Input.is_action_just_pressed("ui_right"):
|
||||
sprite.set_animation("run")
|
||||
state = State.MOVE
|
||||
|
||||
Reference in New Issue
Block a user