Added Infinite Mode; Improved Timer
This commit is contained in:
parent
1245ebc9e8
commit
ed9f671256
9 changed files with 109 additions and 44 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue