Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tgw3ff
2021-SP-CS4096-97-TDG
Commits
5cdc3aee
Commit
5cdc3aee
authored
May 05, 2021
by
Adam Gausmann
Browse files
Add HUD elements
parent
d998a3ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
CS 4096-97 Top Down Game/.mono/metadata/ide_messaging_meta.txt
0 → 100644
View file @
5cdc3aee
62676
C:\Users\adam\Desktop\Godot_v3.2.3-stable_mono_win64\Godot_v3.2.3-stable_mono_win64.exe
CS 4096-97 Top Down Game/Main.tscn
View file @
5cdc3aee
[gd_scene load_steps=
7
format=2]
[gd_scene load_steps=
11
format=2]
[ext_resource path="res://src/Tilemap01.tscn" type="PackedScene" id=1]
[ext_resource path="res://actors/Player.tscn" type="PackedScene" id=2]
...
...
@@ -6,6 +6,17 @@
[ext_resource path="res://ActionManager.gd" type="Script" id=4]
[ext_resource path="res://actors/Enemy.tscn" type="PackedScene" id=5]
[ext_resource path="res://ActorManager.gd" type="Script" id=6]
[ext_resource path="res://assets/MaredivRegular-yeg3.ttf" type="DynamicFontData" id=7]
[sub_resource type="DynamicFont" id=1]
size = 22
font_data = ExtResource( 7 )
[sub_resource type="Theme" id=2]
default_font = SubResource( 1 )
[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 0.141176, 0.0627451, 0.160784, 1 )
[node name="Main" type="Node2D"]
position = Vector2( 224, 112 )
...
...
@@ -28,3 +39,53 @@ position = Vector2( 512, 256 )
[node name="TestEnemy" parent="ActorManager" instance=ExtResource( 5 )]
position = Vector2( 512, 272 )
[node name="GUI" type="CanvasLayer" parent="."]
[node name="HUD" type="MarginContainer" parent="GUI"]
anchor_top = 1.0
anchor_bottom = 1.0
grow_vertical = 0
theme = SubResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Background" type="Panel" parent="GUI/HUD"]
margin_right = 586.0
margin_bottom = 30.0
custom_styles/panel = SubResource( 3 )
[node name="Stats" type="HBoxContainer" parent="GUI/HUD"]
margin_right = 586.0
margin_bottom = 30.0
[node name="Level" type="Label" parent="GUI/HUD/Stats"]
margin_right = 150.0
margin_bottom = 30.0
rect_min_size = Vector2( 150, 0 )
custom_colors/font_color = Color( 0.752941, 0.498039, 0, 1 )
text = "LEVEL 0"
[node name="Health" type="Label" parent="GUI/HUD/Stats"]
margin_left = 154.0
margin_right = 354.0
margin_bottom = 30.0
rect_min_size = Vector2( 200, 0 )
custom_colors/font_color = Color( 0.752941, 0.498039, 0, 1 )
text = "HEALTH 10/10"
[node name="Dash" type="Label" parent="GUI/HUD/Stats"]
margin_left = 358.0
margin_right = 508.0
margin_bottom = 30.0
rect_min_size = Vector2( 150, 0 )
custom_colors/font_color = Color( 0.752941, 0.498039, 0, 1 )
text = "DASH 0"
[node name="High" type="Label" parent="GUI/HUD/Stats"]
margin_left = 512.0
margin_right = 586.0
margin_bottom = 30.0
custom_colors/font_color = Color( 0.752941, 0.498039, 0, 1 )
text = "HIGH 1"
CS 4096-97 Top Down Game/actors/Player.gd
View file @
5cdc3aee
...
...
@@ -130,13 +130,7 @@ func _input(ev):
pass
func
_draw
():
var
label
=
Label
.
new
()
var
font
=
label
.
get_font
(
'
'
)
label
.
queue_free
()
draw_string
(
font
,
Vector2
(
OS
.
window_size
.
x
/
5.5
,
OS
.
window_size
.
y
/
6
),
'
Dashes: '
+
str
(
dashCharges
),
Color
(
1.0
,
1.0
,
0.0
,
1.0
))
draw_string
(
font
,
Vector2
(
OS
.
window_size
.
x
/
5.5
,
OS
.
window_size
.
y
/
5
),
'
Health: '
+
str
(
health
)
+
'
/ '
+
str
(
max_health
),
Color
(
1.0
,
1.0
,
0.0
,
1.0
))
draw_string
(
font
,
Vector2
(
OS
.
window_size
.
x
/
5.5
,
OS
.
window_size
.
y
/
4
),
'
Level: '
+
str
(
level
),
Color
(
1.0
,
1.0
,
0.0
,
1.0
))
draw_string
(
font
,
Vector2
(
OS
.
window_size
.
x
/
5.5
,
OS
.
window_size
.
y
/
8
),
'
High Score: '
+
str
(
high_score
),
Color
(
1.0
,
1.0
,
0.0
,
1.0
))
pass
# Calculates and returns the coordinate of the player in the map by taking its
# current position and dividing by the tile_size
...
...
@@ -145,6 +139,14 @@ func get_coord(p):
return
normalized_position
/
tile_size
func
_process
(
_delta
):
var
level_text
:
Label
=
get_node
(
"/root/Main/GUI/HUD/Stats/Level"
)
level_text
.
text
=
"LEVEL
%d
"
%
level
var
health_text
:
Label
=
get_node
(
"/root/Main/GUI/HUD/Stats/Health"
)
health_text
.
text
=
"HEALTH
%d
/
%d
"
%
[
health
,
max_health
]
var
dash_text
:
Label
=
get_node
(
"/root/Main/GUI/HUD/Stats/Dash"
)
dash_text
.
text
=
"DASH
%d
"
%
dashCharges
var
high_text
:
Label
=
get_node
(
"/root/Main/GUI/HUD/Stats/High"
)
high_text
.
text
=
"HIGH
%d
"
%
high_score
update
()
#func kill():
...
...
CS 4096-97 Top Down Game/assets/MaredivRegular-yeg3.ttf
0 → 100644
View file @
5cdc3aee
File added
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment