Added Infinite Mode; Improved Timer
This commit is contained in:
parent
1245ebc9e8
commit
ed9f671256
9 changed files with 109 additions and 44 deletions
|
|
@ -11,4 +11,4 @@ func _ready() -> void:
|
|||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
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 gameTimer = $GameTimer
|
||||
|
||||
|
||||
var nextBlocks = []
|
||||
|
||||
var currentPattern = null
|
||||
|
|
@ -20,6 +19,18 @@ var blockSpeed = 0.5
|
|||
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:
|
||||
var block = nextBlocks[0]
|
||||
GLOBAL.currentBlock = block
|
||||
|
|
@ -28,10 +39,7 @@ func spawnBlock() -> void:
|
|||
if nextBlocks.size() < 2:
|
||||
fillNextBlocks()
|
||||
|
||||
func _ready() -> void:
|
||||
tickerTimer.start(blockSpeed)
|
||||
getNewPatterns()
|
||||
PlacePattern()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var blockGroups = getBlockGroupsList()
|
||||
|
|
@ -220,10 +228,15 @@ func _on_ticker_timeout() -> void:
|
|||
|
||||
|
||||
func _on_game_timer_timeout() -> void:
|
||||
if GLOBAL.time - 1 > 0:
|
||||
GLOBAL.time -= 1
|
||||
else:
|
||||
GLOBAL.lose()
|
||||
match GLOBAL.currentMode:
|
||||
GLOBAL.MODES.INFINITE:
|
||||
GLOBAL.time += 1
|
||||
GLOBAL.MODES.TIME:
|
||||
if GLOBAL.time - 1 < 0:
|
||||
GLOBAL.lose()
|
||||
else:
|
||||
GLOBAL.time -= 1
|
||||
|
||||
gameTimer.start(1)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ position = Vector2(320, -128)
|
|||
shape = SubResource("RectangleShape2D_m21a1")
|
||||
|
||||
[node name="GameTimer" type="Timer" parent="."]
|
||||
autostart = true
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
position = Vector2(320, 640)
|
||||
|
|
@ -193,7 +192,7 @@ layout_mode = 2
|
|||
|
||||
[node name="Time" type="Label" parent="Camera2D/CanvasLayer/Control/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Time:"
|
||||
text = "Time: "
|
||||
label_settings = ExtResource("9_i2h5u")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue