Skip to content

Commit

Permalink
Disabled SpawnTimer auto-start and enabled one-shot. Fixed rare bug r…
Browse files Browse the repository at this point in the history
…elated to timers not performing timeout actions when the game was paused. Updated version to v0.2.2.
  • Loading branch information
tomas7770 committed May 25, 2020
1 parent b888b21 commit eded797
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion scenes/GlobalVariables.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends Node

const GAME_VERSION = "Development Version (v0.2.1+)"
const GAME_VERSION = "v0.2.2"
var high_score = 0 setget highscore_set, highscore_get # Data ID 0
var sound_mute = false setget mute_set, mute_get # Data ID 1
var sound_shift = false setget sfxshift_set, sfxshift_get # Data ID 2
Expand Down
20 changes: 9 additions & 11 deletions scenes/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,17 @@ func _physics_process(delta):
platX.position.x -= speed*delta

func _on_SpawnTimer_timeout():
if !(GlobalVariables.pause):
var plat = Platform.instance()
add_child(plat)
plat.scale = Vector2(1+randi()%5,min(1+randi()%5,last_height+3)) # 1-5
last_height = plat.scale.y
plat.position = Vector2(screen_size.x+32*plat.scale.x,screen_size.y-32*plat.scale.y)
$SpawnTimer.start(plat.scale.x/(2.0*(speed/200.0)))
var plat = Platform.instance()
add_child(plat)
plat.scale = Vector2(1+randi()%5,min(1+randi()%5,last_height+3)) # 1-5
last_height = plat.scale.y
plat.position = Vector2(screen_size.x+32*plat.scale.x,screen_size.y-32*plat.scale.y)
$SpawnTimer.start(plat.scale.x/(2.0*(speed/200.0)))

func _on_ScoreTimer_timeout():
if !(GlobalVariables.pause):
score += 1
speed += 2
$HUD.update_score(score)
score += 1
speed += 2
$HUD.update_score(score)

func _exit_tree():
GlobalVariables.highscore_set(score)
2 changes: 1 addition & 1 deletion scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ position = Vector2( 128, 598 )

[node name="SpawnTimer" type="Timer" parent="."]
wait_time = 1.5
autostart = true
one_shot = true

[node name="ScoreTimer" type="Timer" parent="."]

Expand Down

0 comments on commit eded797

Please sign in to comment.