Added Infinite Mode; Improved Timer
This commit is contained in:
parent
1245ebc9e8
commit
ed9f671256
9 changed files with 109 additions and 44 deletions
|
|
@ -32,6 +32,10 @@ var time = 60
|
||||||
|
|
||||||
var lost = false
|
var lost = false
|
||||||
|
|
||||||
|
enum MODES {INFINITE, TIME}
|
||||||
|
|
||||||
|
var currentMode = MODES.INFINITE
|
||||||
|
|
||||||
func getNewUID() -> int:
|
func getNewUID() -> int:
|
||||||
lastUID += 1
|
lastUID += 1
|
||||||
return lastUID
|
return lastUID
|
||||||
|
|
@ -42,7 +46,7 @@ func resetGame():
|
||||||
points = 0
|
points = 0
|
||||||
lastUID = 0
|
lastUID = 0
|
||||||
currentUID = lastUID
|
currentUID = lastUID
|
||||||
time = 60
|
resetTime()
|
||||||
lost = false
|
lost = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
@ -50,3 +54,18 @@ func _ready() -> void:
|
||||||
|
|
||||||
func lose():
|
func lose():
|
||||||
lost = true
|
lost = true
|
||||||
|
|
||||||
|
func resetTime():
|
||||||
|
time = 0
|
||||||
|
|
||||||
|
|
||||||
|
func setTimeModeTimer():
|
||||||
|
time = 60
|
||||||
|
|
||||||
|
func convertIntToTime(value) -> String:
|
||||||
|
var time = str(value)
|
||||||
|
var seconds = value % 60
|
||||||
|
var minutes = value / 60
|
||||||
|
if seconds < 10:
|
||||||
|
seconds = "0"+ str(seconds)
|
||||||
|
return str(minutes) + ":" + str(seconds)
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@ func _ready() -> void:
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
scoreLabel.text = str(GLOBAL.points)
|
scoreLabel.text = str(GLOBAL.points)
|
||||||
timeLabel.text = str(GLOBAL.time)
|
timeLabel.text = GLOBAL.convertIntToTime(GLOBAL.time)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ extends Node2D
|
||||||
@onready var loseArea = $LoseArea
|
@onready var loseArea = $LoseArea
|
||||||
@onready var gameTimer = $GameTimer
|
@onready var gameTimer = $GameTimer
|
||||||
|
|
||||||
|
|
||||||
var nextBlocks = []
|
var nextBlocks = []
|
||||||
|
|
||||||
var currentPattern = null
|
var currentPattern = null
|
||||||
|
|
@ -20,6 +19,18 @@ var blockSpeed = 0.5
|
||||||
var stopped = false
|
var stopped = false
|
||||||
|
|
||||||
|
|
||||||
|
func startGame():
|
||||||
|
GLOBAL.resetGame()
|
||||||
|
match GLOBAL.currentMode:
|
||||||
|
GLOBAL.MODES.INFINITE:
|
||||||
|
GLOBAL.resetTime()
|
||||||
|
GLOBAL.MODES.TIME:
|
||||||
|
GLOBAL.setTimeModeTimer()
|
||||||
|
gameTimer.start(1)
|
||||||
|
tickerTimer.start(blockSpeed)
|
||||||
|
getNewPatterns()
|
||||||
|
PlacePattern()
|
||||||
|
|
||||||
func spawnBlock() -> void:
|
func spawnBlock() -> void:
|
||||||
var block = nextBlocks[0]
|
var block = nextBlocks[0]
|
||||||
GLOBAL.currentBlock = block
|
GLOBAL.currentBlock = block
|
||||||
|
|
@ -28,10 +39,7 @@ func spawnBlock() -> void:
|
||||||
if nextBlocks.size() < 2:
|
if nextBlocks.size() < 2:
|
||||||
fillNextBlocks()
|
fillNextBlocks()
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
tickerTimer.start(blockSpeed)
|
|
||||||
getNewPatterns()
|
|
||||||
PlacePattern()
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var blockGroups = getBlockGroupsList()
|
var blockGroups = getBlockGroupsList()
|
||||||
|
|
@ -220,10 +228,15 @@ func _on_ticker_timeout() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_game_timer_timeout() -> void:
|
func _on_game_timer_timeout() -> void:
|
||||||
if GLOBAL.time - 1 > 0:
|
match GLOBAL.currentMode:
|
||||||
GLOBAL.time -= 1
|
GLOBAL.MODES.INFINITE:
|
||||||
else:
|
GLOBAL.time += 1
|
||||||
|
GLOBAL.MODES.TIME:
|
||||||
|
if GLOBAL.time - 1 < 0:
|
||||||
GLOBAL.lose()
|
GLOBAL.lose()
|
||||||
|
else:
|
||||||
|
GLOBAL.time -= 1
|
||||||
|
|
||||||
gameTimer.start(1)
|
gameTimer.start(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,6 @@ position = Vector2(320, -128)
|
||||||
shape = SubResource("RectangleShape2D_m21a1")
|
shape = SubResource("RectangleShape2D_m21a1")
|
||||||
|
|
||||||
[node name="GameTimer" type="Timer" parent="."]
|
[node name="GameTimer" type="Timer" parent="."]
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
position = Vector2(320, 640)
|
position = Vector2(320, 640)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func loadGrid():
|
||||||
$scenes/StartMenu.queue_free()
|
$scenes/StartMenu.queue_free()
|
||||||
scenes.add_child(load("res://scenes/Grid/grid.tscn").instantiate())
|
scenes.add_child(load("res://scenes/Grid/grid.tscn").instantiate())
|
||||||
$scenes/Grid.toggleButton()
|
$scenes/Grid.toggleButton()
|
||||||
|
$scenes/Grid.startGame()
|
||||||
|
|
||||||
func scoreOverview():
|
func scoreOverview():
|
||||||
if $scenes/Grid != null:
|
if $scenes/Grid != null:
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ show_behind_parent = true
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_left = -832.0
|
offset_left = -2856.0
|
||||||
offset_top = -1008.0
|
offset_top = -2504.0
|
||||||
offset_right = 674.0
|
offset_right = 4287.0
|
||||||
offset_bottom = -1991.0
|
offset_bottom = -3032.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
scale = Vector2(0.996259, 9.13391)
|
scale = Vector2(0.996259, 9.13391)
|
||||||
|
|
@ -22,56 +22,86 @@ color = Color(0.000693898, 0.000693898, 0.000693898, 1)
|
||||||
|
|
||||||
[node name="CPUParticles2D" type="CPUParticles2D" parent="ColorRect"]
|
[node name="CPUParticles2D" type="CPUParticles2D" parent="ColorRect"]
|
||||||
modulate = Color(1, 1, 1, 0.478431)
|
modulate = Color(1, 1, 1, 0.478431)
|
||||||
position = Vector2(1300.87, 37.6618)
|
position = Vector2(3195.96, 14.0137)
|
||||||
scale = Vector2(0.501878, 0.054741)
|
scale = Vector2(0.501878, 0.054741)
|
||||||
amount = 20
|
amount = 50
|
||||||
lifetime = 5.0
|
lifetime = 5.0
|
||||||
preprocess = 5.0
|
preprocess = 5.0
|
||||||
speed_scale = 0.5
|
speed_scale = 0.5
|
||||||
local_coords = true
|
local_coords = true
|
||||||
texture = ExtResource("2_5ae6b")
|
texture = ExtResource("2_5ae6b")
|
||||||
emission_shape = 3
|
emission_shape = 3
|
||||||
emission_rect_extents = Vector2(2000, 0)
|
emission_rect_extents = Vector2(4000, 0)
|
||||||
spread = 0.0
|
spread = 0.0
|
||||||
tangential_accel_max = 100.0
|
tangential_accel_max = 100.0
|
||||||
damping_max = 100.0
|
damping_max = 100.0
|
||||||
scale_amount_max = 2.0
|
scale_amount_max = 2.0
|
||||||
|
split_scale = true
|
||||||
|
scale_curve_x = null
|
||||||
|
scale_curve_y = null
|
||||||
color = Color(1, 0, 0, 1)
|
color = Color(1, 0, 0, 1)
|
||||||
|
|
||||||
[node name="CPUParticles2D2" type="CPUParticles2D" parent="ColorRect"]
|
[node name="CPUParticles2D2" type="CPUParticles2D" parent="ColorRect"]
|
||||||
modulate = Color(1, 1, 1, 0.478431)
|
modulate = Color(1, 1, 1, 0.478431)
|
||||||
position = Vector2(1300.87, 37.6618)
|
position = Vector2(3195.96, 14.0137)
|
||||||
scale = Vector2(0.501878, 0.054741)
|
scale = Vector2(0.501878, 0.054741)
|
||||||
amount = 20
|
amount = 50
|
||||||
lifetime = 5.0
|
lifetime = 5.0
|
||||||
preprocess = 5.0
|
preprocess = 5.0
|
||||||
speed_scale = 0.5
|
speed_scale = 0.5
|
||||||
local_coords = true
|
local_coords = true
|
||||||
texture = ExtResource("2_5ae6b")
|
texture = ExtResource("2_5ae6b")
|
||||||
emission_shape = 3
|
emission_shape = 3
|
||||||
emission_rect_extents = Vector2(2000, 0)
|
emission_rect_extents = Vector2(4000, 0)
|
||||||
spread = 0.0
|
spread = 0.0
|
||||||
tangential_accel_max = 100.0
|
tangential_accel_max = 100.0
|
||||||
damping_max = 100.0
|
damping_max = 100.0
|
||||||
scale_amount_max = 2.0
|
scale_amount_max = 2.0
|
||||||
|
split_scale = true
|
||||||
|
scale_curve_x = null
|
||||||
|
scale_curve_y = null
|
||||||
color = Color(0, 0.0499997, 1, 1)
|
color = Color(0, 0.0499997, 1, 1)
|
||||||
|
|
||||||
[node name="CPUParticles2D3" type="CPUParticles2D" parent="ColorRect"]
|
[node name="CPUParticles2D3" type="CPUParticles2D" parent="ColorRect"]
|
||||||
modulate = Color(1, 1, 1, 0.478431)
|
modulate = Color(1, 1, 1, 0.478431)
|
||||||
position = Vector2(1300.87, 37.6618)
|
position = Vector2(3195.96, 14.0137)
|
||||||
scale = Vector2(0.501878, 0.054741)
|
scale = Vector2(0.501878, 0.054741)
|
||||||
amount = 20
|
amount = 50
|
||||||
lifetime = 5.0
|
lifetime = 5.0
|
||||||
preprocess = 5.0
|
preprocess = 5.0
|
||||||
speed_scale = 0.5
|
speed_scale = 0.5
|
||||||
local_coords = true
|
local_coords = true
|
||||||
texture = ExtResource("2_5ae6b")
|
texture = ExtResource("2_5ae6b")
|
||||||
emission_shape = 3
|
emission_shape = 3
|
||||||
emission_rect_extents = Vector2(2000, 0)
|
emission_rect_extents = Vector2(4000, 0)
|
||||||
spread = 0.0
|
spread = 0.0
|
||||||
tangential_accel_max = 100.0
|
tangential_accel_max = 100.0
|
||||||
damping_max = 100.0
|
damping_max = 100.0
|
||||||
scale_amount_max = 2.0
|
scale_amount_max = 2.0
|
||||||
|
split_scale = true
|
||||||
|
scale_curve_x = null
|
||||||
|
scale_curve_y = null
|
||||||
color = Color(0.966667, 1, 0, 1)
|
color = Color(0.966667, 1, 0, 1)
|
||||||
|
|
||||||
|
[node name="CPUParticles2D4" type="CPUParticles2D" parent="ColorRect"]
|
||||||
|
modulate = Color(1, 1, 1, 0.478431)
|
||||||
|
position = Vector2(3195.96, 14.0137)
|
||||||
|
scale = Vector2(0.501878, 0.054741)
|
||||||
|
amount = 50
|
||||||
|
lifetime = 5.0
|
||||||
|
preprocess = 5.0
|
||||||
|
speed_scale = 0.5
|
||||||
|
local_coords = true
|
||||||
|
texture = ExtResource("2_5ae6b")
|
||||||
|
emission_shape = 3
|
||||||
|
emission_rect_extents = Vector2(4000, 0)
|
||||||
|
spread = 0.0
|
||||||
|
tangential_accel_max = 100.0
|
||||||
|
damping_max = 100.0
|
||||||
|
scale_amount_max = 2.0
|
||||||
|
split_scale = true
|
||||||
|
scale_curve_x = null
|
||||||
|
scale_curve_y = null
|
||||||
|
color = Color(0.138, 0.92, 0, 1)
|
||||||
|
|
||||||
[node name="scenes" type="Node" parent="."]
|
[node name="scenes" type="Node" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,10 @@ func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func _on_start_button_pressed() -> void:
|
func _on_infinite_mode_button_pressed() -> void:
|
||||||
|
GLOBAL.currentMode = GLOBAL.MODES.INFINITE
|
||||||
|
get_parent().get_parent().loadGrid()
|
||||||
|
|
||||||
|
func _on_time_mode_button_pressed() -> void:
|
||||||
|
GLOBAL.currentMode = GLOBAL.MODES.TIME
|
||||||
get_parent().get_parent().loadGrid()
|
get_parent().get_parent().loadGrid()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ grow_vertical = 2
|
||||||
theme = ExtResource("1_t0oee")
|
theme = ExtResource("1_t0oee")
|
||||||
script = ExtResource("2_1x51p")
|
script = ExtResource("2_1x51p")
|
||||||
|
|
||||||
[node name="StartButton" type="Button" parent="."]
|
[node name="VBoxContainer2" type="VBoxContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 7
|
anchors_preset = 7
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
|
@ -27,13 +27,19 @@ anchor_top = 1.0
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_left = -156.0
|
offset_left = -156.0
|
||||||
offset_top = -320.0
|
offset_top = -448.0
|
||||||
offset_right = 4.0
|
offset_right = 164.0
|
||||||
offset_bottom = -224.0
|
offset_bottom = -256.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
scale = Vector2(2, 2)
|
|
||||||
text = "Start"
|
[node name="InfiniteModeButton" type="Button" parent="VBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Infinite Mode"
|
||||||
|
|
||||||
|
[node name="TimeModeButton" type="Button" parent="VBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Time Mode"
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
@ -111,4 +117,5 @@ alignment = 1
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
texture = ExtResource("7_mn4r0")
|
texture = ExtResource("7_mn4r0")
|
||||||
|
|
||||||
[connection signal="pressed" from="StartButton" to="." method="_on_start_button_pressed"]
|
[connection signal="pressed" from="VBoxContainer2/InfiniteModeButton" to="." method="_on_infinite_mode_button_pressed"]
|
||||||
|
[connection signal="pressed" from="VBoxContainer2/TimeModeButton" to="." method="_on_time_mode_button_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,8 @@ func _ready() -> void:
|
||||||
time.text = str(GLOBAL.time)
|
time.text = str(GLOBAL.time)
|
||||||
GLOBAL.resetGame()
|
GLOBAL.resetGame()
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_play_again_button_pressed() -> void:
|
func _on_play_again_button_pressed() -> void:
|
||||||
get_parent().get_parent().laodGrid()
|
get_parent().get_parent().loadGrid()
|
||||||
|
|
||||||
|
|
||||||
func _on_home_pressed() -> void:
|
func _on_home_pressed() -> void:
|
||||||
get_parent().get_parent().loadStartMenu()
|
get_parent().get_parent().loadStartMenu()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue