summaryrefslogtreecommitdiff
path: root/world.gd
diff options
context:
space:
mode:
Diffstat (limited to 'world.gd')
-rw-r--r--world.gd42
1 files changed, 41 insertions, 1 deletions
diff --git a/world.gd b/world.gd
index ce18ba1..fa2b6dd 100644
--- a/world.gd
+++ b/world.gd
@@ -19,10 +19,50 @@ func _ready():
var mob = scene.instantiate()
add_child(Game.spawn_mob(mob, $Spawn))
await get_tree().create_timer(randi_range(1, 2)).timeout
+ #await get_tree().create_timer(0.01).timeout
#break
+func _draw():
+ if Game.debug:
+ var area = Game.path_grid.region
+ var cell_size = Game.path_grid.cell_size
+ var offset = Game.path_grid.offset
+ for row in range(0, area.size.y + 1):
+ draw_line(
+ Vector2(offset.x, offset.y + row * cell_size.y),
+ Vector2(offset.x + area.size.x * cell_size.x, offset.y + row * cell_size.y),
+ Color(1, 1, 0, 0.25),
+ 1.0
+ )
+ for column in range(0, area.size.x + 1):
+ draw_line(
+ Vector2(offset.x + column * cell_size.x, offset.y),
+ Vector2(offset.x + column * cell_size.x, offset.y + area.size.y * cell_size.y),
+ Color(1, 1, 0, 0.25),
+ 1.0
+ )
+
+ for row in range(0, area.size.y):
+ for column in range(0, area.size.x):
+ if Game.path_grid.is_point_solid(Vector2i(column, row)):
+ draw_circle(
+ Vector2(
+ offset.x + column * cell_size.x + cell_size.x/2,
+ offset.y + row * cell_size.y + cell_size.y/2
+ ),
+ 1,
+ Color(1, 1, 0, 0.25)
+ )
+
+
func _input(event: InputEvent):
+ if event.is_action_pressed("ui_accept"):
+ for _i in range(0, 2):
+ var scene = preload("res://Mob.tscn")
+ var mob = scene.instantiate()
+ add_child(Game.spawn_mob(mob, $Spawn))
+
if Game.mode == Game.Mode.DEFAULT:
if event.is_action_pressed("builder_tower_select"):
if Tower.selected_tower:
@@ -37,7 +77,7 @@ func _input(event: InputEvent):
if current_builder_element.can_build():
var placed_tower = current_builder_element.element.duplicate() as Tower
- Game.place_tower(placed_tower, get_global_mouse_position().snapped(Vector2(16, 16)))
+ Game.place_tower(placed_tower, get_global_mouse_position().snapped(Game.map.tile_set.tile_size))
placed_tower.selected.connect(func():
%Tower.text = "Range: %s - Power: %s - Speed: %s" % [