diff --git a/art/fonts/DraftingMono-Regular.ttf b/art/fonts/DraftingMono-Regular.ttf new file mode 100644 index 0000000..630e91d Binary files /dev/null and b/art/fonts/DraftingMono-Regular.ttf differ diff --git a/art/fonts/DraftingMono-Regular.ttf.import b/art/fonts/DraftingMono-Regular.ttf.import new file mode 100644 index 0000000..3314bff --- /dev/null +++ b/art/fonts/DraftingMono-Regular.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://8guv2d1fgna7" +path="res://.godot/imported/DraftingMono-Regular.ttf-2613f107ee7cfa148009be1dfb779785.fontdata" + +[deps] + +source_file="res://art/fonts/DraftingMono-Regular.ttf" +dest_files=["res://.godot/imported/DraftingMono-Regular.ttf-2613f107ee7cfa148009be1dfb779785.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/scenes/hud.tscn b/scenes/hud.tscn new file mode 100644 index 0000000..31c86b9 --- /dev/null +++ b/scenes/hud.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://bxj8v34v1igyc"] + +[ext_resource type="Script" path="res://scripts/hud.gd" id="1_glf76"] +[ext_resource type="FontFile" uid="uid://8guv2d1fgna7" path="res://art/fonts/DraftingMono-Regular.ttf" id="1_xr1ih"] + +[node name="HUD" type="CanvasLayer"] +script = ExtResource("1_glf76") + +[node name="ScoreLabel" type="Label" parent="."] +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -60.0 +offset_bottom = 41.0 +grow_horizontal = 0 +theme_override_fonts/font = ExtResource("1_xr1ih") +theme_override_font_sizes/font_size = 30 +text = "0" diff --git a/scenes/main.tscn b/scenes/main.tscn index 79eec7f..d45f6d9 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,11 +1,14 @@ -[gd_scene load_steps=4 format=3 uid="uid://cdwgmtyq2y8sm"] +[gd_scene load_steps=6 format=3 uid="uid://cdwgmtyq2y8sm"] +[ext_resource type="Script" path="res://scripts/main.gd" id="1_1xo8b"] [ext_resource type="PackedScene" uid="uid://m8uyi35gr3qd" path="res://scenes/tile_map.tscn" id="2_c6bkg"] [ext_resource type="PackedScene" uid="uid://ba1t35yyot4jl" path="res://scenes/player.tscn" id="2_idv37"] [ext_resource type="PackedScene" uid="uid://bktg1ypaav3q3" path="res://scenes/enemy.tscn" id="3_2xcd4"] +[ext_resource type="PackedScene" uid="uid://bxj8v34v1igyc" path="res://scenes/hud.tscn" id="4_ealqo"] [node name="Main" type="Node2D"] y_sort_enabled = true +script = ExtResource("1_1xo8b") [node name="TileMap" parent="." instance=ExtResource("2_c6bkg")] position = Vector2(324, 82) @@ -19,3 +22,7 @@ position = Vector2(0, 40) z_index = 1 z_as_relative = false y_sort_enabled = true + +[node name="HUD" parent="." instance=ExtResource("4_ealqo")] + +[connection signal="hit_ball" from="TileMap/Player" to="." method="_on_player_hit_ball"] diff --git a/scripts/hud.gd b/scripts/hud.gd new file mode 100644 index 0000000..85524b4 --- /dev/null +++ b/scripts/hud.gd @@ -0,0 +1,4 @@ +extends CanvasLayer + +func update_score(score): + $ScoreLabel.text = str(score) diff --git a/scripts/main.gd b/scripts/main.gd new file mode 100644 index 0000000..dd5777c --- /dev/null +++ b/scripts/main.gd @@ -0,0 +1,7 @@ +extends Node2D + +var score = 0 + +func _on_player_hit_ball(): + score += 1 + $HUD.update_score(score)