fixed movements
This commit is contained in:
parent
77a13eb2c8
commit
84fd007069
|
@ -17,6 +17,7 @@ __meta__ = {
|
|||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||
position = Vector2( 445, 205 )
|
||||
z_index = 1
|
||||
speed = 20
|
||||
speed = 20.0
|
||||
rest = 0.2
|
||||
tile_position = Vector2( 4, 2 )
|
||||
grid_path = NodePath("..")
|
||||
|
|
15
Player.gd
15
Player.gd
|
@ -2,13 +2,16 @@ tool
|
|||
extends Area2D
|
||||
|
||||
|
||||
export var speed = 1
|
||||
export var speed : float = 1
|
||||
export var rest : float = 1
|
||||
|
||||
export var tile_position := Vector2(0,0)
|
||||
export(NodePath) var grid_path
|
||||
|
||||
onready var grid = get_node(grid_path) as TileMap
|
||||
|
||||
var last_move_time := 0.0
|
||||
|
||||
class Movement:
|
||||
var action: String
|
||||
var direction: Vector2
|
||||
|
@ -49,10 +52,11 @@ func _process(delta):
|
|||
|
||||
else:
|
||||
|
||||
for movement in movements:
|
||||
if Input.is_action_just_pressed(movement.action):
|
||||
movement_queue.push_back(movement)
|
||||
|
||||
if (last_move_time + rest) * 1000 < OS.get_ticks_msec():
|
||||
for movement in movements:
|
||||
if Input.is_action_pressed(movement.action):
|
||||
movement_queue.push_back(movement)
|
||||
|
||||
update_animation()
|
||||
|
||||
if not movement_queue.empty():
|
||||
|
@ -72,6 +76,7 @@ func _process(delta):
|
|||
movement_queue.pop_front()
|
||||
|
||||
update_position()
|
||||
last_move_time = OS.get_ticks_msec() / 1000.0
|
||||
|
||||
|
||||
func update_position():
|
||||
|
|
Loading…
Reference in New Issue