Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main level and High Score #27

Merged
merged 7 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/GUI/AmmoGUI.gd
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
extends HBoxContainer
extends PanelContainer

var ammo_texture := preload("res://assets/player/acid_shot_2.png")
var ammo_container_node := "HeartContainer"
var ammo_container_node := "AmmoContainer"

onready var ammo_holder: HBoxContainer = $AmmoHolder


func _on_Player_max_ammo_changed(ammo: int) -> void:
for child in get_children():
remove_child(child)
for child in ammo_holder.get_children():
ammo_holder.remove_child(child)
child.queue_free()
for i in ammo:
var ammo_container := TextureRect.new()
ammo_container.name = ammo_container_node
ammo_container.texture = ammo_texture
var center_container := CenterContainer.new()
center_container.add_child(ammo_container)
add_child(center_container)
ammo_holder.add_child(center_container)


func _on_Player_ammo_changed(ammo: int) -> void:
for i in get_child_count():
var ammo_container: TextureRect = get_child(i).get_node(ammo_container_node)
for i in ammo_holder.get_child_count():
var ammo_container: TextureRect = ammo_holder.get_child(i).get_node(ammo_container_node)
ammo_container.modulate = Color(1, 1, 1, 1) if ammo > i else Color(0.1, 0.1, 0.1, 0.5)
41 changes: 28 additions & 13 deletions src/GUI/AmmoGUI.tscn
Original file line number Diff line number Diff line change
@@ -1,75 +1,90 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]

[ext_resource path="res://assets/player/acid_shot_2.png" type="Texture" id=1]
[ext_resource path="res://src/GUI/AmmoGUI.gd" type="Script" id=2]
[ext_resource path="res://src/GUI/GameTheme.tres" type="Theme" id=3]

[node name="AmmoGUI" type="HBoxContainer"]
size_flags_vertical = 4
[node name="AmmoGUI" type="PanelContainer"]
margin_right = 157.0
margin_bottom = 29.0
rect_min_size = Vector2( 0, 46 )
size_flags_vertical = 8
theme = ExtResource( 3 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderCenterContainer" type="CenterContainer" parent="."]
[node name="AmmoHolder" type="HBoxContainer" parent="."]
margin_left = 8.0
margin_top = 16.0
margin_right = 149.0
margin_bottom = 29.0
size_flags_vertical = 4
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderCenterContainer" type="CenterContainer" parent="AmmoHolder"]
margin_right = 25.0
margin_bottom = 13.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderTextureRect" type="TextureRect" parent="PlaceHolderCenterContainer"]
[node name="PlaceHolderTextureRect" type="TextureRect" parent="AmmoHolder/PlaceHolderCenterContainer"]
margin_right = 25.0
margin_bottom = 13.0
texture = ExtResource( 1 )

[node name="PlaceHolderCenterContainer5" type="CenterContainer" parent="."]
[node name="PlaceHolderCenterContainer5" type="CenterContainer" parent="AmmoHolder"]
margin_left = 29.0
margin_right = 54.0
margin_bottom = 13.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderTextureRect" type="TextureRect" parent="PlaceHolderCenterContainer5"]
[node name="PlaceHolderTextureRect" type="TextureRect" parent="AmmoHolder/PlaceHolderCenterContainer5"]
margin_right = 25.0
margin_bottom = 13.0
texture = ExtResource( 1 )

[node name="PlaceHolderCenterContainer4" type="CenterContainer" parent="."]
[node name="PlaceHolderCenterContainer4" type="CenterContainer" parent="AmmoHolder"]
margin_left = 58.0
margin_right = 83.0
margin_bottom = 13.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderTextureRect" type="TextureRect" parent="PlaceHolderCenterContainer4"]
[node name="PlaceHolderTextureRect" type="TextureRect" parent="AmmoHolder/PlaceHolderCenterContainer4"]
margin_right = 25.0
margin_bottom = 13.0
texture = ExtResource( 1 )

[node name="PlaceHolderCenterContainer3" type="CenterContainer" parent="."]
[node name="PlaceHolderCenterContainer3" type="CenterContainer" parent="AmmoHolder"]
margin_left = 87.0
margin_right = 112.0
margin_bottom = 13.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderTextureRect" type="TextureRect" parent="PlaceHolderCenterContainer3"]
[node name="PlaceHolderTextureRect" type="TextureRect" parent="AmmoHolder/PlaceHolderCenterContainer3"]
margin_right = 25.0
margin_bottom = 13.0
texture = ExtResource( 1 )

[node name="PlaceHolderCenterContainer2" type="CenterContainer" parent="."]
[node name="PlaceHolderCenterContainer2" type="CenterContainer" parent="AmmoHolder"]
margin_left = 116.0
margin_right = 141.0
margin_bottom = 13.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlaceHolderTextureRect" type="TextureRect" parent="PlaceHolderCenterContainer2"]
[node name="PlaceHolderTextureRect" type="TextureRect" parent="AmmoHolder/PlaceHolderCenterContainer2"]
margin_right = 25.0
margin_bottom = 13.0
texture = ExtResource( 1 )
11 changes: 7 additions & 4 deletions src/GUI/GameGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class_name GameGUI
export(NodePath) var player_path

onready var player: Player = get_node(player_path)
onready var health_gui = $CenterContainer/HBoxContainer/PanelContainer/HealthGUI
onready var ammo_gui = $CenterContainer/HBoxContainer/PanelContainer2/AmmoGUI
onready var score_gui = $CenterContainer/HBoxContainer/PanelContainer3/ScoreGUI
onready var health_gui = $HBoxContainer/HealthGUI
onready var ammo_gui = $HBoxContainer/AmmoGUI
onready var score_gui = $HBoxContainer/ScoreGUI
onready var pause_menu = $CanvasLayer/PauseMenu
onready var game_over_menu = $CanvasLayer/GameOverMenu

Expand Down Expand Up @@ -41,9 +41,12 @@ func _unhandled_input(event: InputEvent) -> void:


func _on_Player_health_depleted() -> void:
score_gui.save_high_score()
game_over_menu.show()


func _process(_delta: float) -> void:
game_over_menu.time = score_gui.time
game_over_menu.score = score_gui.adjusted_score
game_over_menu.score = score_gui.score_adjusted
game_over_menu.high_time = score_gui.high_time
game_over_menu.high_score = score_gui.high_score_adjusted
78 changes: 28 additions & 50 deletions src/GUI/GameGUI.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -23,68 +23,46 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_left = 0.1
anchor_top = 0.9
anchor_right = 0.9
anchor_bottom = 0.9
margin_left = -20.0
margin_top = -40.0
margin_right = 20.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer"]
margin_left = 43.0
margin_right = 508.0
margin_bottom = 46.0
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchor_top = 0.925
anchor_right = 1.0
anchor_bottom = 0.925
margin_top = -80.0
custom_constants/separation = 64
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PanelContainer" type="PanelContainer" parent="CenterContainer/HBoxContainer"]
margin_right = 84.0
margin_bottom = 46.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HealthGUI" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 37.0
margin_top = 34.0
margin_right = 121.0
margin_bottom = 80.0

[node name="HealthGUI" parent="CenterContainer/HBoxContainer/PanelContainer" instance=ExtResource( 1 )]
margin_left = 8.0
margin_top = 12.0
margin_right = 76.0
margin_bottom = 33.0
[node name="AmmoGUI" parent="HBoxContainer" instance=ExtResource( 2 )]
margin_left = 185.0
margin_top = 34.0
margin_right = 342.0
margin_bottom = 80.0

[node name="PanelContainer2" type="PanelContainer" parent="CenterContainer/HBoxContainer"]
margin_left = 148.0
margin_right = 305.0
margin_bottom = 46.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScoreGUI" parent="HBoxContainer" instance=ExtResource( 7 )]
margin_left = 406.0
margin_right = 602.0
margin_bottom = 80.0

[node name="AmmoGUI" parent="CenterContainer/HBoxContainer/PanelContainer2" instance=ExtResource( 2 )]
margin_left = 8.0
margin_top = 16.0
margin_right = 149.0
margin_bottom = 29.0

[node name="PanelContainer3" type="PanelContainer" parent="CenterContainer/HBoxContainer"]
margin_left = 369.0
margin_right = 465.0
margin_bottom = 46.0
[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_left = 0.1
anchor_top = 0.9
anchor_right = 0.9
anchor_bottom = 0.9
margin_left = -20.0
margin_top = -40.0
margin_right = 20.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ScoreGUI" parent="CenterContainer/HBoxContainer/PanelContainer3" instance=ExtResource( 7 )]
margin_left = 8.0
margin_top = 8.0
margin_right = 88.0
margin_bottom = 38.0

[node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = 100

Expand Down
20 changes: 18 additions & 2 deletions src/GUI/GameOverMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ extends Control

var score := 0.0 setget set_score
var time := 0.0 setget set_time
var high_score := 0.0 setget set_high_score
var high_time := 0.0 setget set_high_time

onready var audio_stream_player: AudioStreamPlayer = $AudioStreamPlayer
onready var time_value: Label = $Background/ColorRect/CenterContainer/VBoxContainer/TimeContainer/PanelContainer/TimeValue
onready var score_value: Label = $Background/ColorRect/CenterContainer/VBoxContainer/ScoreContainer/PanelContainer/ScoreValue
onready var time_value: Label = $Background/ColorRect/CenterContainer/VBoxContainer/GridContainer/TimePanelContainer/TimeValue
onready var score_value: Label = $Background/ColorRect/CenterContainer/VBoxContainer/GridContainer/ScorePanelContainer/ScoreValue
onready var high_time_value: Label = $Background/ColorRect/CenterContainer/VBoxContainer/GridContainer/HighTimePanelContainer/HighTimeValue
onready var high_score_value: Label = $Background/ColorRect/CenterContainer/VBoxContainer/GridContainer/HighScorePanelContainer/HighScoreValue


func show() -> void:
Expand All @@ -26,6 +30,18 @@ func set_score(value: float) -> void:
score_value.text = "%.0f" % (score)


func set_high_time(value: float) -> void:
if high_time != value:
high_time = value
high_time_value.text = "%.0f" % (high_time)


func set_high_score(value: float) -> void:
if high_score != value:
high_score = value
high_score_value.text = "%.0f" % (high_score)


func _on_ContinueButton_pressed() -> void:
get_tree().paused = false
var connected := get_tree().reload_current_scene()
Expand Down