summaryrefslogtreecommitdiff
path: root/scenes/levels/puzzle/puzzle.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scenes/levels/puzzle/puzzle.gd')
-rw-r--r--scenes/levels/puzzle/puzzle.gd16
1 files changed, 12 insertions, 4 deletions
diff --git a/scenes/levels/puzzle/puzzle.gd b/scenes/levels/puzzle/puzzle.gd
index 982bb29..746e33e 100644
--- a/scenes/levels/puzzle/puzzle.gd
+++ b/scenes/levels/puzzle/puzzle.gd
@@ -7,10 +7,13 @@ const _button_comp = preload("res://components/button.tscn")
const dim = 4
var parts = []
-onready var order = range(dim*dim)
+onready var order = []
func _ready():
for i in range(dim*dim-1):
+ order.append(i+1)
+ order.append(0)
+ for i in range(dim*dim-1):
var button = _button_comp.instance()
var label = Label.new()
label.name = "CustomLabel"
@@ -32,7 +35,10 @@ func _position_from_index(idx):
func _unhandled_input(event):
if running and event is InputEventKey and event.pressed and event.scancode == KEY_K:
- order = range(dim*dim)
+ order = []
+ for i in range(dim*dim-1):
+ order.append(i+1)
+ order.append(0)
_render_state()
_check_state()
@@ -51,9 +57,11 @@ func _render_state():
piece.position = _position_from_index(i) * 80
func _check_state():
- for i in range(dim*dim):
- if order[i] != i:
+ for i in range(dim*dim-1):
+ if order[i] != i+1:
return
+ if order[dim*dim-1] != 0:
+ return
finish_level()