Display funds on screen

This commit is contained in:
Olivier 'reivilibre' 2023-01-08 22:04:40 +00:00
parent 40a2075779
commit f41f32380a
7 changed files with 68 additions and 8 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://scenery/tiles/ohld_tileset.tres" type="TileSet" id=1] [ext_resource path="res://scenery/tiles/ohld_tileset.tres" type="TileSet" id=1]
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2] [ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
@ -7,6 +7,7 @@
[ext_resource path="res://scenery/facilities/Press.tscn" type="PackedScene" id=5] [ext_resource path="res://scenery/facilities/Press.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenery/tiles/road.png" type="Texture" id=6] [ext_resource path="res://scenery/tiles/road.png" type="Texture" id=6]
[ext_resource path="res://vehicles/Postie.tscn" type="PackedScene" id=7] [ext_resource path="res://vehicles/Postie.tscn" type="PackedScene" id=7]
[ext_resource path="res://ui/Hud.tscn" type="PackedScene" id=8]
[sub_resource type="TileSet" id=1] [sub_resource type="TileSet" id=1]
0/name = "road.png 0" 0/name = "road.png 0"
@ -70,3 +71,7 @@ position = Vector2( 418, 768 )
[node name="MarkerRoadPoint" type="Node2D" parent="World"] [node name="MarkerRoadPoint" type="Node2D" parent="World"]
position = Vector2( 328, 770 ) position = Vector2( 328, 770 )
[node name="Hud" parent="." instance=ExtResource( 8 )]
margin_right = 1261.0
margin_bottom = 740.0

7
ui/Hud.gd Normal file
View File

@ -0,0 +1,7 @@
extends Node2D
var coin = 0
func add_coin(amount: int):
coin += amount
$HudInner/Panel/LabelCoin.text = str(coin)

34
ui/Hud.tscn Normal file
View File

@ -0,0 +1,34 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://ui/normal_font.tres" type="DynamicFont" id=1]
[ext_resource path="res://ui/coin.png" type="Texture" id=2]
[ext_resource path="res://ui/Hud.gd" type="Script" id=3]
[node name="Hud" type="Node2D"]
z_index = 50
script = ExtResource( 3 )
__meta__ = {
"_editor_description_": "wrapper Node2D for z-index override"
}
[node name="HudInner" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0
[node name="Panel" type="Panel" parent="HudInner"]
margin_left = 1280.0
margin_top = 712.0
margin_right = 1600.0
margin_bottom = 904.0
[node name="LabelCoin" type="Label" parent="HudInner/Panel"]
margin_left = 50.0
margin_top = 24.0
margin_right = 90.0
margin_bottom = 51.0
custom_fonts/font = ExtResource( 1 )
text = "0"
[node name="Coin" type="Sprite" parent="HudInner/Panel"]
position = Vector2( 31, 37 )
texture = ExtResource( 2 )

7
ui/normal_font.tres Normal file
View File

@ -0,0 +1,7 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://fonts/Gidolinya-Regular-SubsetOHLD52.otf" type="DynamicFontData" id=1]
[resource]
size = 24
font_data = ExtResource( 1 )

10
ui/normal_theme.tres Normal file
View File

@ -0,0 +1,10 @@
[gd_resource type="Theme" load_steps=3 format=2]
[ext_resource path="res://ui/normal_font.tres" type="DynamicFont" id=1]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.0745098, 0.0980392, 0.027451, 1 )
[resource]
default_font = ExtResource( 1 )
Panel/styles/panel = SubResource( 1 )

View File

@ -85,6 +85,7 @@ func _on_driven_off():
print("trying to sell ", body, " but no value!") print("trying to sell ", body, " but no value!")
print("coin made: ", coin_made) print("coin made: ", coin_made)
find_parent("Level*").get_node("Hud").add_coin(coin_made)
func _on_Tween_tween_all_completed(): func _on_Tween_tween_all_completed():
if state == "driving_in": if state == "driving_in":

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2] [gd_scene load_steps=16 format=2]
[ext_resource path="res://vehicles/postie_backramp.png" type="Texture" id=1] [ext_resource path="res://vehicles/postie_backramp.png" type="Texture" id=1]
[ext_resource path="res://vehicles/postie_back.png" type="Texture" id=2] [ext_resource path="res://vehicles/postie_back.png" type="Texture" id=2]
@ -9,7 +9,7 @@
[ext_resource path="res://sfx/backgate_open.wav" type="AudioStream" id=7] [ext_resource path="res://sfx/backgate_open.wav" type="AudioStream" id=7]
[ext_resource path="res://sfx/backgate_closed.wav" type="AudioStream" id=8] [ext_resource path="res://sfx/backgate_closed.wav" type="AudioStream" id=8]
[ext_resource path="res://sfx/engine_start_and_drive.wav" type="AudioStream" id=9] [ext_resource path="res://sfx/engine_start_and_drive.wav" type="AudioStream" id=9]
[ext_resource path="res://fonts/Gidolinya-Regular-SubsetOHLD52.otf" type="DynamicFontData" id=10] [ext_resource path="res://ui/normal_font.tres" type="DynamicFont" id=10]
[ext_resource path="res://ui/coin.png" type="Texture" id=11] [ext_resource path="res://ui/coin.png" type="Texture" id=11]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
@ -24,10 +24,6 @@ extents = Vector2( 92.5, 1.5 )
[sub_resource type="RectangleShape2D" id=4] [sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 89, 47 ) extents = Vector2( 89, 47 )
[sub_resource type="DynamicFont" id=5]
size = 24
font_data = ExtResource( 10 )
[node name="Postie" type="Node2D"] [node name="Postie" type="Node2D"]
script = ExtResource( 5 ) script = ExtResource( 5 )
@ -97,7 +93,7 @@ margin_top = -82.0
margin_right = 204.0 margin_right = 204.0
margin_bottom = -25.0 margin_bottom = -25.0
custom_colors/font_color = Color( 0, 0.192157, 0.0196078, 1 ) custom_colors/font_color = Color( 0, 0.192157, 0.0196078, 1 )
custom_fonts/font = SubResource( 5 ) custom_fonts/font = ExtResource( 10 )
text = "Total Sale Value: text = "Total Sale Value:
0" 0"