Skip to content

Commit

Permalink
Add generated music; game over now displays stats
Browse files Browse the repository at this point in the history
  • Loading branch information
svntax committed Jun 27, 2016
1 parent 9845354 commit fa88116
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 0 deletions.
Binary file modified Scenes/gameover_ui.scn
Binary file not shown.
Binary file modified Scenes/main_menu.scn
Binary file not shown.
Binary file added Scenes/music_handler.scn
Binary file not shown.
1 change: 1 addition & 0 deletions Scripts/cavebat_controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func _fixed_process(delta):
if(animTimer >= find_node("Particles2D").get_lifetime() - 0.1):
set_pos(Vector2(-100, -100))
get_node("Particles2D").set_emitting(false)
get_node("/root/globals").incrementKills()
queue_free()

func checkCollision():
Expand Down
1 change: 1 addition & 0 deletions Scripts/exit_controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ func _ready():

func _fixed_process(delta):
if(overlaps_body(player)):
get_node("/root/globals").incrementLevel()
for enemy in get_tree().get_nodes_in_group("enemies"):
enemy.queue_free()
get_tree().reload_current_scene()
Expand Down
13 changes: 13 additions & 0 deletions Scripts/gameover_controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ func toggle():
var x = playerCam.get_camera_pos().x - (w / 4)
var y = playerCam.get_camera_pos().y - (h / 4)
set_pos(Vector2(x, y + 40))

var levelLabel = get_node("LevelLabel")
var killsLabel = get_node("KillsLabel")
var level = get_node("/root/globals").getLevelReached()
var kills = get_node("/root/globals").getEnemiesKilled()
levelLabel.set_text("Level reached: " + str(level))
killsLabel.set_text("Enemies killed: " + str(kills))

func _on_Button_pressed():
get_tree().set_pause(false)

var musicHandler = get_node("/root/music_handler")
if(musicHandler.is_playing()):
musicHandler.stop()

get_node("/root/globals").resetStats()
get_tree().change_scene("res://Scenes/main_menu.scn")
hide()
24 changes: 24 additions & 0 deletions Scripts/global.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

extends Node

var ENEMIES_KILLED = 0
var LEVEL_REACHED = 1

func _ready():
pass

func getEnemiesKilled():
return ENEMIES_KILLED

func getLevelReached():
return LEVEL_REACHED

func incrementKills():
ENEMIES_KILLED += 1

func incrementLevel():
LEVEL_REACHED += 1

func resetStats():
ENEMIES_KILLED = 0
LEVEL_REACHED = 1
4 changes: 4 additions & 0 deletions Scripts/main_menu_controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ func _ready():
pass

func _on_StartButton_pressed():
var musicHandler = get_node("/root/music_handler")
if(!musicHandler.is_playing()):
musicHandler.set_volume(2)
musicHandler.play()
get_tree().change_scene("res://test_scene.scn")

func _on_QuitButton_pressed():
Expand Down
5 changes: 5 additions & 0 deletions Scripts/pause_menu_controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func toggle():

func _on_YesButton_pressed():
get_tree().set_pause(false)

var musicHandler = get_node("/root/music_handler")
if(musicHandler.is_playing()):
musicHandler.stop()

get_tree().change_scene("res://Scenes/main_menu.scn")
hide()

Expand Down
Binary file added Sounds/random_cave_song.ogg
Binary file not shown.
2 changes: 2 additions & 0 deletions engine.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ icon="res://icon.png"

[autoload]

globals="*res://Scripts/global.gd"
music_handler="*res://Scenes/music_handler.scn"
sound_effects="*res://Scenes/sound_effects.scn"

[display]
Expand Down

0 comments on commit fa88116

Please sign in to comment.