1
0
Fork 0

add collisions

This commit is contained in:
Manu 2021-04-25 01:55:01 +02:00
parent b4529d4c75
commit ae47cf7b5d
2 changed files with 8 additions and 2 deletions

View File

@ -17,3 +17,4 @@ tile_data = PoolIntArray( 393216, 0, 0, 393217, 0, 0, 393219, 0, 0, 393220, 0, 0
position = Vector2( 800, 440 )
tile_position = Vector2( 8, 5 )
grid_path = NodePath("../..")
props_path = NodePath("..")

View File

@ -6,9 +6,11 @@ export var speed : float = 1
export var rest : float = 1
export var tile_position := Vector2(0,0)
export(NodePath) var grid_path
export(NodePath) var grid_path
export(NodePath) var props_path
onready var grid = get_node(grid_path) as TileMap
onready var props = get_node(props_path) as TileMap
var last_move_time := 0.0
@ -35,6 +37,7 @@ onready var sprite = $AnimatedSprite as AnimatedSprite
func _process(delta):
if Engine.editor_hint:
@ -55,7 +58,9 @@ func _process(delta):
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)
var target = tile_position + movement.direction
if grid.get_cell(target.x, target.y) >= 0 and props.get_cell(target.x, target.y) == -1:
movement_queue.push_back(movement)
update_animation()