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):
2222 pass
2323
2424func next (action ):
25- if array .get (_index ) > array .get (_index + 1 ):
25+ if array .at (_index ) > array .at (_index + 1 ):
2626 if action != null and action != ACTIONS .SWAP :
2727 return emit_signal ("mistake" )
2828 array .swap (_index , _index + 1 )
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func _init(array).(array):
2222 pass
2323
2424func next (action ):
25- if array .get (_index - 1 ) > array .get (_index ):
25+ if array .at (_index - 1 ) > array .at (_index ):
2626 if action != null and action != ACTIONS .SWAP :
2727 return emit_signal ("mistake" )
2828 array .swap (_index - 1 , _index )
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ func next(action):
3232 if action != null and action != ACTIONS .LEFT :
3333 return emit_signal ("mistake" )
3434 _left += 1
35- elif array .get (_left ) <= array .get (_right ):
35+ elif array .at (_left ) <= array .at (_right ):
3636 if action != null and action != ACTIONS .LEFT :
3737 return emit_signal ("mistake" )
3838 _left += 1
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func _init(array).(array):
2222 pass
2323
2424func next (action ):
25- if array .get (_base ) > array .get (_index ):
25+ if array .at (_base ) > array .at (_index ):
2626 if action != null and action != ACTIONS .SWAP :
2727 return emit_signal ("mistake" )
2828 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-
61class_name ArrayModel
72extends Reference
83
@@ -16,7 +11,7 @@ func _init(size=16):
1611 array .shuffle ()
1712 self .size = size
1813
19- func get (i ):
14+ func at (i ):
2015 """Retrieve the value of the element at index i."""
2116 return array [i ]
2217
Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ _global_script_classes=[ {
4545"path" : "res://levels/merge_sort.gd"
4646}, {
4747"base" : "ComparisonSort" ,
48+ "class" : "QuickSort" ,
49+ "language" : "GDScript" ,
50+ "path" : "res://levels/quick_sort.gd"
51+ }, {
52+ "base" : "ComparisonSort" ,
4853"class" : "SelectionSort" ,
4954"language" : "GDScript" ,
5055"path" : "res://levels/selection_sort.gd"
@@ -57,6 +62,7 @@ _global_script_class_icons={
5762"ComparisonSort" : "" ,
5863"InsertionSort" : "" ,
5964"MergeSort" : "" ,
65+ "QuickSort" : "" ,
6066"SelectionSort" : ""
6167}
6268
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ var levels = [
55 InsertionSort ,
66 SelectionSort ,
77 MergeSort ,
8+ QuickSort ,
89]
910var level : ComparisonSort
1011
@@ -27,7 +28,7 @@ func _ready():
2728 bottom_button .focus_neighbour_bottom = top_button .get_path ()
2829 # If no last played level, autofocus first level
2930 if GlobalScene .get_param ("level" ) == null :
30- top_button .grab_focus ()
31+ bottom_button .grab_focus ()
3132
3233func _on_Button_focus_changed ():
3334 """Initialize the preview section."""
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ func _process(delta):
2525 for i in range (level .array .size ):
2626 rects [i ].rect_scale .y = - 1 # HACK: Override scale to bypass weird behavior
2727 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
2929
3030func _on_Level_mistake ():
3131 """Flash the border red on mistakes."""
You can’t perform that action at this time.
0 commit comments