File tree Expand file tree Collapse file tree 8 files changed +14
-12
lines changed Expand file tree Collapse file tree 8 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func _init(array).(array):
22
22
pass
23
23
24
24
func next (action ):
25
- if array .get (_index ) > array .get (_index + 1 ):
25
+ if array .at (_index ) > array .at (_index + 1 ):
26
26
if action != null and action != ACTIONS .SWAP :
27
27
return emit_signal ("mistake" )
28
28
array .swap (_index , _index + 1 )
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func _init(array).(array):
22
22
pass
23
23
24
24
func next (action ):
25
- if array .get (_index - 1 ) > array .get (_index ):
25
+ if array .at (_index - 1 ) > array .at (_index ):
26
26
if action != null and action != ACTIONS .SWAP :
27
27
return emit_signal ("mistake" )
28
28
array .swap (_index - 1 , _index )
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ func next(action):
32
32
if action != null and action != ACTIONS .LEFT :
33
33
return emit_signal ("mistake" )
34
34
_left += 1
35
- elif array .get (_left ) <= array .get (_right ):
35
+ elif array .at (_left ) <= array .at (_right ):
36
36
if action != null and action != ACTIONS .LEFT :
37
37
return emit_signal ("mistake" )
38
38
_left += 1
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func _init(array).(array):
22
22
pass
23
23
24
24
func next (action ):
25
- if array .get (_base ) > array .get (_index ):
25
+ if array .at (_base ) > array .at (_index ):
26
26
if action != null and action != ACTIONS .SWAP :
27
27
return emit_signal ("mistake" )
28
28
array .swap (_base , _index )
Original file line number Diff line number Diff line change 1
- """
2
- A plain old one-dimensional random access array wrapper around the
3
- built-in class.
4
- """
5
-
6
1
class_name ArrayModel
7
2
extends Reference
8
3
@@ -16,7 +11,7 @@ func _init(size=16):
16
11
array .shuffle ()
17
12
self .size = size
18
13
19
- func get (i ):
14
+ func at (i ):
20
15
"""Retrieve the value of the element at index i."""
21
16
return array [i ]
22
17
Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ _global_script_classes=[ {
45
45
"path" : "res://levels/merge_sort.gd"
46
46
}, {
47
47
"base" : "ComparisonSort" ,
48
+ "class" : "QuickSort" ,
49
+ "language" : "GDScript" ,
50
+ "path" : "res://levels/quick_sort.gd"
51
+ }, {
52
+ "base" : "ComparisonSort" ,
48
53
"class" : "SelectionSort" ,
49
54
"language" : "GDScript" ,
50
55
"path" : "res://levels/selection_sort.gd"
@@ -57,6 +62,7 @@ _global_script_class_icons={
57
62
"ComparisonSort" : "" ,
58
63
"InsertionSort" : "" ,
59
64
"MergeSort" : "" ,
65
+ "QuickSort" : "" ,
60
66
"SelectionSort" : ""
61
67
}
62
68
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ var levels = [
5
5
InsertionSort ,
6
6
SelectionSort ,
7
7
MergeSort ,
8
+ QuickSort ,
8
9
]
9
10
var level : ComparisonSort
10
11
@@ -27,7 +28,7 @@ func _ready():
27
28
bottom_button .focus_neighbour_bottom = top_button .get_path ()
28
29
# If no last played level, autofocus first level
29
30
if GlobalScene .get_param ("level" ) == null :
30
- top_button .grab_focus ()
31
+ bottom_button .grab_focus ()
31
32
32
33
func _on_Button_focus_changed ():
33
34
"""Initialize the preview section."""
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ func _process(delta):
25
25
for i in range (level .array .size ):
26
26
rects [i ].rect_scale .y = - 1 # HACK: Override scale to bypass weird behavior
27
27
rects [i ].color = level .get_effect (i )
28
- rects [i ].rect_size .y = rect_size .y * level .array .get (i ) / level .array .size
28
+ rects [i ].rect_size .y = rect_size .y * level .array .at (i ) / level .array .size
29
29
30
30
func _on_Level_mistake ():
31
31
"""Flash the border red on mistakes."""
You can’t perform that action at this time.
0 commit comments