Skip to content

Commit 96414dc

Browse files
committed
style: prefix private variables with underscore
1 parent 9aae4e3 commit 96414dc

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

models/array_model.gd

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,41 @@ extends Reference
33

44
signal swapped(i, j) # where i <= j
55

6-
var array = []
7-
var size = 0
6+
var _array = []
7+
var size = 0 setget , get_size
88

99
func _init(size=16):
1010
"""Randomize the array."""
1111
for i in range(1, size + 1):
12-
array.append(i)
13-
array.shuffle()
14-
self.size = array.size()
12+
_array.append(i)
13+
_array.shuffle()
1514

1615
func at(i):
1716
"""Retrieve the value of the element at index i."""
18-
return array[i]
17+
return _array[i]
1918

2019
func is_sorted():
2120
"""Check if the array is in monotonically increasing order."""
2221
for i in range(size - 1):
23-
if array[i] > array[i + 1]:
22+
if _array[i] > _array[i + 1]:
2423
return false
2524
return true
2625

2726
func swap(i, j):
2827
"""Swap the elements at indices i and j."""
29-
var temp = array[i]
30-
array[i] = array[j]
31-
array[j] = temp
28+
var temp = _array[i]
29+
_array[i] = _array[j]
30+
_array[j] = temp
3231
emit_signal("swapped", min(i, j), max(i, j))
3332

3433
func sort(i, j):
3534
"""Sort the subarray starting at i and up to but not including j."""
3635
# Grr to the developer who made the upper bound inclusive
37-
var front = array.slice(0, i - 1) if i != 0 else []
38-
var sorted = array.slice(i, j - 1)
36+
var front = _array.slice(0, i - 1) if i != 0 else []
37+
var sorted = _array.slice(i, j - 1)
3938
sorted.sort()
40-
var back = array.slice(j, size - 1) if j != size else []
41-
array = front + sorted + back
39+
var back = _array.slice(j, size - 1) if j != size else []
40+
_array = front + sorted + back
41+
42+
func get_size():
43+
return _array.size()

project.godot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ GlobalTheme="*res://scripts/theme.gd"
7777

7878
window/size/width=1920
7979
window/size/height=1080
80-
window/size/fullscreen=true
8180
window/size/always_on_top=true
8281
window/dpi/allow_hidpi=true
8382
window/stretch/mode="2d"

scripts/credits.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ func _process(delta):
1010
rect_position.y -= 1
1111

1212
func _input(event):
13-
GlobalScene.change_scene("res://scenes/menu.tscn")
13+
if event.is_pressed():
14+
GlobalScene.change_scene("res://scenes/menu.tscn")

0 commit comments

Comments
 (0)