Skip to content

Commit

Permalink
Fuel and Health pickup sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
tewecske committed Jun 1, 2024
1 parent 9edfa4b commit 48213e7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
5 changes: 2 additions & 3 deletions scenes/fuel/fuel_cannister.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
extends Area2D

#func _ready():
#if get_parent().fuel_timer.time_left <= 0:
#get_parent().fuel_timer.start(5)
signal fuel_collected

func _process(delta):
position.y += 200 * delta
Expand All @@ -14,6 +12,7 @@ func _on_area_entered(area):
else:
SystemData.player_fuel = SystemData.player_max_fuel
get_parent().fuel_timer.start(5)
fuel_collected.emit()
SystemData.fuel_collected += 1
self.queue_free()

Expand Down
3 changes: 3 additions & 0 deletions scenes/health/wrench.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
extends Area2D

signal health_collected

func _ready():
if get_parent().health_timer.time_left <= 0:
get_parent().health_timer.start(3)
Expand All @@ -14,6 +16,7 @@ func _on_area_entered(area):
else:
SystemData.player_health = SystemData.player_max_health
get_parent().health_timer.start(3)
health_collected.emit()
SystemData.health_collected += 1
self.queue_free()

Expand Down
14 changes: 12 additions & 2 deletions scenes/main game scene/game_scene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://cehk7cuewxedv"]
[gd_scene load_steps=22 format=3 uid="uid://cehk7cuewxedv"]

[ext_resource type="Script" path="res://scenes/main game scene/main.gd" id="1_3072i"]
[ext_resource type="PackedScene" uid="uid://bjxr0iep468t3" path="res://scenes/falling objects/new_asteroid.tscn" id="2_5md3b"]
Expand All @@ -18,6 +18,8 @@
[ext_resource type="Texture2D" uid="uid://bawrb5fuv5gkd" path="res://sprites/RedBarSmall.png" id="13_1fafh"]
[ext_resource type="AudioStream" uid="uid://eyhht1ggaqt" path="res://Bonus/fight.ogg" id="13_p2uwh"]
[ext_resource type="AudioStream" uid="uid://cctcv3ifduv6f" path="res://Sounds/Low Fuel 1.wav" id="18_036r0"]
[ext_resource type="AudioStream" uid="uid://bsm4tfodob0oo" path="res://Sounds/Pickup Wrench.wav" id="19_fk81j"]
[ext_resource type="AudioStream" uid="uid://d1uft6xtaotmm" path="res://Sounds/Fuel.wav" id="20_bi8ii"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_qnm1o"]
size = Vector2(2816, 16)
Expand Down Expand Up @@ -275,7 +277,7 @@ visible = false

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("13_p2uwh")
volume_db = -10.0
volume_db = -15.0
autoplay = true
bus = &"Music"

Expand All @@ -284,6 +286,14 @@ stream = ExtResource("18_036r0")
volume_db = -15.0
bus = &"SFX"

[node name="AudioPickupWrench" type="AudioStreamPlayer" parent="."]
stream = ExtResource("19_fk81j")
bus = &"SFX"

[node name="AudioFuel" type="AudioStreamPlayer" parent="."]
stream = ExtResource("20_bi8ii")
volume_db = -10.0

[connection signal="area_entered" from="Area2D" to="." method="_on_viewport_area_entered"]
[connection signal="area_exited" from="Area2D" to="." method="_on_viewport_area_exited"]
[connection signal="timeout" from="GUILayer/MainGUIContainer/TopMarginContainer/GridContainer/MidMarginContainer/NoFuelBlinkTimer" to="." method="no_fuel"]
10 changes: 10 additions & 0 deletions scenes/main game scene/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extends Node2D
@onready var fuel_progress_bar = $GUILayer/MainGUIContainer/MidMarginContainer/GridContainer/CenterMarginContainer/OutsideGridContainer/MarginContainer/CenterContainer/GridContainer/FuelProgressBar

@onready var audio_low_fuel: AudioStreamPlayer = $AudioLowFuel
@onready var audio_fuel: AudioStreamPlayer = $AudioFuel
@onready var audio_pickup_wrench: AudioStreamPlayer = $AudioPickupWrench

@onready var parallax_background: ParallaxBackground = $ParallaxBackground

Expand Down Expand Up @@ -121,13 +123,21 @@ func _on_FallingObjectTimer_timeout():
func _on_FuelTimer_timeout():
var fuel_object = fuel_collect_scene.instantiate()
add_child(fuel_object)
fuel_object.connect("fuel_collected", _on_fuel_collected)
fuel_object.position = Vector2(randi_range(16, (get_viewport_rect().size.x * 2) - 16), falling_object_area.global_position.y)

func _on_HealthTimer_timeout():
var health_object = health_collect_scene.instantiate()
add_child(health_object)
health_object.connect("health_collected", _on_health_collected)
health_object.position = Vector2(randi_range(16, (get_viewport_rect().size.x * 2) - 16), falling_object_area.global_position.y)

func _on_health_collected():
audio_pickup_wrench.play()

func _on_fuel_collected():
audio_fuel.play()

func on_player_hit():
#if SystemData.shield_health > 0:
if SystemData.shield_health > 0:
Expand Down

0 comments on commit 48213e7

Please sign in to comment.