summaryrefslogtreecommitdiff
path: root/UI/LevelSelect.gd
blob: 7abc5f2bc4e379157c442349a97b4068ca49fdb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extends Control


func _ready():
	Global.connect("level_map_updated", self, "draw")
	draw()


func draw():
	var Cell = load("res://UI/LevelSelectCell.tscn")
	
	for idx in range(9):
		var cell = Cell.instance()
		cell.level_idx = idx
		cell.set_rect_size(1024/3, 600/3)
		var column = idx % 3
		var row = idx / 3
		cell.rect_position.x = cell.rect_size.x*column
		cell.rect_position.y = cell.rect_size.y*row
		cell.connect("gui_input", self, '_button_pressed', [idx])
		self.add_child(cell)


func _button_pressed(event, idx):
	if event is InputEventMouseButton or event is InputEventKey:
		if event.pressed:
			Global.start_level(idx)