2020-04-19 12:10:17 -05:00
|
|
|
extends Node
|
|
|
|
|
2020-04-19 20:31:03 -04:00
|
|
|
const SPACE = 50
|
|
|
|
|
|
|
|
var rock = preload("res://Rock.tscn")
|
|
|
|
var empty = preload("res://Empty.tscn")
|
|
|
|
|
2020-04-19 12:10:17 -05:00
|
|
|
var level_map = null
|
|
|
|
var player = null
|
2020-04-19 17:39:48 -04:00
|
|
|
var enemy = null
|
2020-04-19 12:10:17 -05:00
|
|
|
|
2020-04-19 17:39:48 -04:00
|
|
|
var player_pos = Vector2()
|
|
|
|
var enemy_pos = Vector2()
|
|
|
|
|
|
|
|
func _init(lvlmap, plr, enm):
|
2020-04-19 12:10:17 -05:00
|
|
|
level_map = lvlmap
|
|
|
|
player = plr
|
2020-04-19 17:39:48 -04:00
|
|
|
enemy = enm
|
2020-04-19 16:16:40 -04:00
|
|
|
|
|
|
|
func get_type(pos):
|
|
|
|
print(level_map[pos.y][pos.x].type)
|
|
|
|
return level_map[pos.y][pos.x].type
|
2020-04-19 20:31:03 -04:00
|
|
|
|
|
|
|
# We only expect having to set Empty and Rock types
|
|
|
|
func set_pos(pos, type):
|
|
|
|
if type == "Rock":
|
|
|
|
level_map[pos.y][pos.x].queue_free()
|
|
|
|
var instance = rock.instance()
|
|
|
|
level_map[pos.y][pos.x] = instance
|
|
|
|
instance.global_position = Vector2(pos.x*SPACE, pos.y*SPACE)
|
|
|
|
elif type == "Empty":
|
|
|
|
level_map[pos.y][pos.x].queue_free()
|
|
|
|
var instance = empty.instance()
|
|
|
|
level_map[pos.y][pos.x] = instance
|
|
|
|
instance.global_position = Vector2(pos.x*SPACE, pos.y*SPACE)
|
|
|
|
|