diff --git a/entities/player/scripts/player.gd b/entities/player/scripts/player.gd index d265772..c6b9a3f 100644 --- a/entities/player/scripts/player.gd +++ b/entities/player/scripts/player.gd @@ -1,12 +1,22 @@ extends CharacterBody2D class_name Player +signal player_stats_updated(player : Player) + @export var speed = 400 +var energy : int = 10 : + set(v): + energy = v + emit_signal("player_stats_updated", self) + +func _ready(): + emit_signal("player_stats_updated", self) + func get_input(): calculate_direction() - if Input.is_action_just_pressed("interact"): + if Input.is_action_just_pressed("interact") and energy > 0: try_interact() func calculate_direction(): @@ -31,6 +41,7 @@ func try_interact(): ) interactables[0].interact(self) + energy -= 1 func _physics_process(_delta): get_input() diff --git a/gui/player_info/assets/icons/bolt.svg b/gui/player_info/assets/icons/bolt.svg new file mode 100644 index 0000000..03e1ce7 --- /dev/null +++ b/gui/player_info/assets/icons/bolt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/gui/player_info/assets/icons/bolt.svg.import b/gui/player_info/assets/icons/bolt.svg.import new file mode 100644 index 0000000..c0ae8b5 --- /dev/null +++ b/gui/player_info/assets/icons/bolt.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcgnamu7sb3ov" +path="res://.godot/imported/bolt.svg-346ec638bad7861a6c0a47abfe0480f6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/player_info/assets/icons/bolt.svg" +dest_files=["res://.godot/imported/bolt.svg-346ec638bad7861a6c0a47abfe0480f6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/gui/player_info/assets/texture/Interface sans boutons.png b/gui/player_info/assets/texture/Interface sans boutons.png new file mode 100644 index 0000000..c84f850 Binary files /dev/null and b/gui/player_info/assets/texture/Interface sans boutons.png differ diff --git a/gui/player_info/assets/texture/Interface sans boutons.png.import b/gui/player_info/assets/texture/Interface sans boutons.png.import new file mode 100644 index 0000000..94b685b --- /dev/null +++ b/gui/player_info/assets/texture/Interface sans boutons.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cm3ehinvvj52i" +path="res://.godot/imported/Interface sans boutons.png-6f58a6b9570fde0ac2945334970770a8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/player_info/assets/texture/Interface sans boutons.png" +dest_files=["res://.godot/imported/Interface sans boutons.png-6f58a6b9570fde0ac2945334970770a8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/gui/player_info/player_info.tscn b/gui/player_info/player_info.tscn new file mode 100644 index 0000000..ea4ffa3 --- /dev/null +++ b/gui/player_info/player_info.tscn @@ -0,0 +1,62 @@ +[gd_scene load_steps=6 format=3 uid="uid://baqrmhsgqda6v"] + +[ext_resource type="Script" uid="uid://bpqh8n0lbluf8" path="res://gui/player_info/scripts/player_info.gd" id="1_ghu0s"] +[ext_resource type="Texture2D" uid="uid://cm3ehinvvj52i" path="res://gui/player_info/assets/texture/Interface sans boutons.png" id="2_cgy6f"] +[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/player_info/assets/icons/bolt.svg" id="3_s4ggy"] +[ext_resource type="FontFile" uid="uid://byyfovm1ha5ya" path="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" id="4_5y5ny"] + +[sub_resource type="LabelSettings" id="LabelSettings_bye71"] +font = ExtResource("4_5y5ny") +font_size = 25 + +[node name="PlayerInfo" type="Control"] +custom_minimum_size = Vector2(337, 160) +layout_mode = 3 +anchor_right = 0.293 +anchor_bottom = 0.247 +offset_right = -0.536011 +offset_bottom = -0.0559998 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 0 +size_flags_vertical = 0 +script = ExtResource("1_ghu0s") + +[node name="Background" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_cgy6f") +expand_mode = 2 +stretch_mode = 5 + +[node name="EnergyInfo" type="HBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.281899 +anchor_top = 0.384375 +anchor_right = 0.281899 +anchor_bottom = 0.584375 +offset_left = -44.0 +offset_top = -12.5 +offset_right = 44.0 +offset_bottom = 12.5 +grow_horizontal = 2 +grow_vertical = 2 +metadata/_edit_use_anchors_ = true + +[node name="Icon" type="TextureRect" parent="EnergyInfo"] +custom_minimum_size = Vector2(36.64, 0) +layout_mode = 2 +texture = ExtResource("3_s4ggy") +stretch_mode = 5 + +[node name="Label" type="Label" parent="EnergyInfo"] +layout_mode = 2 +text = "0" +label_settings = SubResource("LabelSettings_bye71") +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/gui/player_info/scripts/player_info.gd b/gui/player_info/scripts/player_info.gd new file mode 100644 index 0000000..d2a45eb --- /dev/null +++ b/gui/player_info/scripts/player_info.gd @@ -0,0 +1,4 @@ +extends Control + +func _on_root_gui_player_stats_updated(player:Player): + $EnergyInfo/Label.text = str(player.energy) diff --git a/gui/player_info/scripts/player_info.gd.uid b/gui/player_info/scripts/player_info.gd.uid new file mode 100644 index 0000000..0c5d2ca --- /dev/null +++ b/gui/player_info/scripts/player_info.gd.uid @@ -0,0 +1 @@ +uid://bpqh8n0lbluf8 diff --git a/gui/ressources/fonts/AtomicMd-3zXDZ.ttf b/gui/ressources/fonts/AtomicMd-3zXDZ.ttf new file mode 100644 index 0000000..708b503 Binary files /dev/null and b/gui/ressources/fonts/AtomicMd-3zXDZ.ttf differ diff --git a/gui/ressources/fonts/AtomicMd-3zXDZ.ttf.import b/gui/ressources/fonts/AtomicMd-3zXDZ.ttf.import new file mode 100644 index 0000000..4750024 --- /dev/null +++ b/gui/ressources/fonts/AtomicMd-3zXDZ.ttf.import @@ -0,0 +1,35 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://byyfovm1ha5ya" +path="res://.godot/imported/AtomicMd-3zXDZ.ttf-0d8ee2c5d0b5b97084be121e0cf9710b.fontdata" + +[deps] + +source_file="res://gui/ressources/fonts/AtomicMd-3zXDZ.ttf" +dest_files=["res://.godot/imported/AtomicMd-3zXDZ.ttf-0d8ee2c5d0b5b97084be121e0cf9710b.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=4 +keep_rounding_remainders=true +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/gui/root_gui.tscn b/gui/root_gui.tscn new file mode 100644 index 0000000..6c16cc0 --- /dev/null +++ b/gui/root_gui.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=3 format=3 uid="uid://12nak7amd1uq"] + +[ext_resource type="PackedScene" uid="uid://baqrmhsgqda6v" path="res://gui/player_info/player_info.tscn" id="1_8kw6x"] +[ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/scripts/root_gui.gd" id="1_udau0"] + +[node name="RootGui" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource("1_udau0") + +[node name="PlayerInfo" parent="." instance=ExtResource("1_8kw6x")] +layout_mode = 1 +anchors_preset = 0 +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_right = 337.0 +offset_bottom = 160.0 +grow_horizontal = 1 +grow_vertical = 1 + +[connection signal="player_stats_updated" from="." to="PlayerInfo" method="_on_root_gui_player_stats_updated"] diff --git a/gui/scripts/root_gui.gd b/gui/scripts/root_gui.gd new file mode 100644 index 0000000..b9679a9 --- /dev/null +++ b/gui/scripts/root_gui.gd @@ -0,0 +1,7 @@ +extends Control +class_name RootGui + +signal player_stats_updated(player : Player) + +func _on_player_player_stats_updated(player:Player): + emit_signal("player_stats_updated", player) diff --git a/gui/scripts/root_gui.gd.uid b/gui/scripts/root_gui.gd.uid new file mode 100644 index 0000000..4dcfe95 --- /dev/null +++ b/gui/scripts/root_gui.gd.uid @@ -0,0 +1 @@ +uid://cqao7n800qy40 diff --git a/root.tscn b/root.tscn index f8a1d18..092edc9 100644 --- a/root.tscn +++ b/root.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=5 format=3 uid="uid://c5bruelvqbm1k"] +[gd_scene load_steps=6 format=3 uid="uid://c5bruelvqbm1k"] +[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/root_gui.tscn" id="1_jnlp7"] [ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/planet/planet.tscn" id="1_pyidc"] [ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="2_vvh5c"] [ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_vvh5c"] @@ -7,6 +8,10 @@ [node name="Root" type="Node2D"] +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="RootGui" parent="CanvasLayer" instance=ExtResource("1_jnlp7")] + [node name="Planet" parent="." instance=ExtResource("1_pyidc")] [node name="Player" parent="." instance=ExtResource("2_vvh5c")] @@ -15,32 +20,36 @@ position = Vector2(2.22, 0) following = NodePath("../Player") -[node name="DefaultPlant" parent="." instance=ExtResource("4_28aoi")] +[node name="TestPlants" type="Node2D" parent="."] + +[node name="DefaultPlant" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(195, 37) -[node name="DefaultPlant2" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant2" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(114, -40) -[node name="DefaultPlant3" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant3" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(-222, 138) -[node name="DefaultPlant4" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant4" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(-186, -96) -[node name="DefaultPlant5" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant5" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(-7, 150) -[node name="DefaultPlant6" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant6" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(-19, -102) -[node name="DefaultPlant7" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant7" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(-115, 50) -[node name="DefaultPlant8" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant8" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(147, -173) -[node name="DefaultPlant9" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant9" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(98, 90) -[node name="DefaultPlant10" parent="." instance=ExtResource("4_28aoi")] +[node name="DefaultPlant10" parent="TestPlants" instance=ExtResource("4_28aoi")] position = Vector2(-269, 1) + +[connection signal="player_stats_updated" from="Player" to="CanvasLayer/RootGui" method="_on_player_player_stats_updated"]