Commit 5cdc3aee authored by Adam Gausmann's avatar Adam Gausmann
Browse files

Add HUD elements

parent d998a3ad
62676
C:\Users\adam\Desktop\Godot_v3.2.3-stable_mono_win64\Godot_v3.2.3-stable_mono_win64.exe
[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"
......@@ -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():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment