From 660c13980f1c879a3fa4da13882f839924c723fe Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Tue, 10 Oct 2023 20:26:50 -0400 Subject: [PATCH] spawnable tests and hpbar for bebittes --- Assets/Fonts/alagard.ttf | Bin 0 -> 13544 bytes Assets/Fonts/alagard.ttf.import | 38 ++++++++++++++++++++++ Scenes/Levels/level_1.tscn | 13 ++++++-- Scenes/Levels/level_test.tscn | 14 ++------ Scenes/Player/player.gd | 16 +++++++++ Scenes/Player/player.tscn | 8 +++++ Scenes/Spawnables/UI/SpawnableUI.gd | 7 ++++ Scenes/Spawnables/UI/SpawnableUI.tscn | 10 ++++-- Scenes/Spawnables/template_spawnable.gd | 2 +- Scenes/Spawnables/template_spawnable.tscn | 4 +-- Scenes/enemy.tscn | 1 + Themes/base_theme.tres | 14 ++++++++ project.godot | 6 ++++ 13 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 Assets/Fonts/alagard.ttf create mode 100644 Assets/Fonts/alagard.ttf.import create mode 100644 Scenes/Player/player.gd create mode 100644 Scenes/Player/player.tscn create mode 100644 Themes/base_theme.tres diff --git a/Assets/Fonts/alagard.ttf b/Assets/Fonts/alagard.ttf new file mode 100644 index 0000000000000000000000000000000000000000..c7ed1d91950f994bd6c71efba69332a0459d26e4 GIT binary patch literal 13544 zcmb_jTZ|l6wcSg;{?W9@xTl_e075lJPI=lAY?V&AjJpE@sc=S8%xyZ_$%_R6TNNBu3- z*FW<3*6m;X;n|W%a2)jmhfXe@+5aCqUKNQBqU}?MUOqQ18^iw+DP`y{9b0_y%+eA@ zmOI}>ec;#&pE)`|w&N9%@@pcuzjpk{;^E6b-Ti0u{RPL4<7lX?kG_MkHle=h_{nqU zfBjJS2I?7(*Izh&XmS3HFAL|2qxRU|cb*&F^MA6cga(mc{q3_)`Rh`)ltg41{7T3Ret0I5 zr9=*vWGQ1=N762LI;JhhdRVXF5_nAlkUisur2Hq~~Hr_Yj>zeler>i$TqtmBJo$5o%na?ho% zFL77)p^bC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N{d>3-lJ@DucK_>~gzX#v`-HZLly;vDMfHmlY zc&qRbAsiF yp02)h>O=#AvFQf*e-QvlH}?_D!8`|utgXIBuRp)?z2EW9U!0%4n^*q-p8p4nmwE;O literal 0 HcmV?d00001 diff --git a/Assets/Fonts/alagard.ttf.import b/Assets/Fonts/alagard.ttf.import new file mode 100644 index 0000000..8efddb9 --- /dev/null +++ b/Assets/Fonts/alagard.ttf.import @@ -0,0 +1,38 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://01mccw37teq2" +path="res://.godot/imported/alagard.ttf-ed7015ed0e84e70ec06fd3d65515ce04.fontdata" + +[deps] + +source_file="res://Assets/Fonts/alagard.ttf" +dest_files=["res://.godot/imported/alagard.ttf-ed7015ed0e84e70ec06fd3d65515ce04.fontdata"] + +[params] + +Rendering=null +antialiasing=0 +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=0 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=false +preload=[{ +"chars": [], +"glyphs": [], +"name": "New Configuration", +"size": Vector2i(16, 0) +}] +language_support={} +script_support={} +opentype_features={} diff --git a/Scenes/Levels/level_1.tscn b/Scenes/Levels/level_1.tscn index 90a2dc8..17023d5 100644 --- a/Scenes/Levels/level_1.tscn +++ b/Scenes/Levels/level_1.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=4 format=3 uid="uid://uoyiei4wyig3"] +[gd_scene load_steps=6 format=3 uid="uid://uoyiei4wyig3"] [ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_4n82n"] -[ext_resource type="PackedScene" uid="uid://dgtscjxcqoxls" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"] -[ext_resource type="PackedScene" uid="uid://cf7al5uln33rn" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"] +[ext_resource type="PackedScene" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"] +[ext_resource type="PackedScene" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"] +[ext_resource type="PackedScene" uid="uid://b5lnjonlf4i1b" path="res://Scenes/enemy.tscn" id="4_g0oey"] +[ext_resource type="PackedScene" uid="uid://0onqgygm832d" path="res://Scenes/Player/player.tscn" id="5_ik47y"] [node name="Level1" type="Node2D"] @@ -33,3 +35,8 @@ position = Vector2(528, 224) [node name="Candle4" parent="Decor" instance=ExtResource("2_5hdq4")] position = Vector2(528, 320) + +[node name="Enemy" parent="." instance=ExtResource("4_g0oey")] +position = Vector2(481.898, 270.98) + +[node name="Player" parent="." instance=ExtResource("5_ik47y")] diff --git a/Scenes/Levels/level_test.tscn b/Scenes/Levels/level_test.tscn index 55860cd..d6ac0fb 100644 --- a/Scenes/Levels/level_test.tscn +++ b/Scenes/Levels/level_test.tscn @@ -2,7 +2,7 @@ [ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_287nl"] [ext_resource type="PackedScene" uid="uid://b5lnjonlf4i1b" path="res://Scenes/enemy.tscn" id="2_ftshv"] -[ext_resource type="PackedScene" uid="uid://brnx3xyyd0e71" path="res://Scenes/Spawnables/bat_spawnable.tscn" id="3_a1ucf"] +[ext_resource type="PackedScene" uid="uid://0onqgygm832d" path="res://Scenes/Player/player.tscn" id="4_dvauv"] [node name="Level1" type="Node2D"] @@ -13,14 +13,4 @@ [node name="Enemy" parent="." instance=ExtResource("2_ftshv")] position = Vector2(497, 324) -[node name="BatSpawnable" parent="." instance=ExtResource("3_a1ucf")] -position = Vector2(248, 225) -collision_layer = 6 -collision_mask = 6 -motion_mode = 0 - -[node name="BatSpawnable2" parent="." instance=ExtResource("3_a1ucf")] -position = Vector2(644, 251) -collision_layer = 6 -collision_mask = 6 -motion_mode = 0 +[node name="Player" parent="." instance=ExtResource("4_dvauv")] diff --git a/Scenes/Player/player.gd b/Scenes/Player/player.gd new file mode 100644 index 0000000..a43d2e1 --- /dev/null +++ b/Scenes/Player/player.gd @@ -0,0 +1,16 @@ +extends Node2D + +@export var batTemplatePath : PackedScene + +func _ready(): + pass + +func _process(delta): + if Input.is_action_just_pressed("place_spawnable"): + spawnBat() + +func spawnBat(): + var bat = batTemplatePath.instantiate() + bat.global_position = get_global_mouse_position() + $"..".add_child(bat) + $"../Enemy".add_foe(bat) diff --git a/Scenes/Player/player.tscn b/Scenes/Player/player.tscn new file mode 100644 index 0000000..cc0e9f0 --- /dev/null +++ b/Scenes/Player/player.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=3 format=3 uid="uid://0onqgygm832d"] + +[ext_resource type="Script" path="res://Scenes/Player/player.gd" id="1_63swt"] +[ext_resource type="PackedScene" uid="uid://brnx3xyyd0e71" path="res://Scenes/Spawnables/bat_spawnable.tscn" id="2_fd41r"] + +[node name="Player" type="Node2D"] +script = ExtResource("1_63swt") +batTemplatePath = ExtResource("2_fd41r") diff --git a/Scenes/Spawnables/UI/SpawnableUI.gd b/Scenes/Spawnables/UI/SpawnableUI.gd index d61e4aa..80d06e7 100644 --- a/Scenes/Spawnables/UI/SpawnableUI.gd +++ b/Scenes/Spawnables/UI/SpawnableUI.gd @@ -2,9 +2,16 @@ extends Control @onready var healthBar : ProgressBar = $HealthBar @onready var hpLabel : Label = $HealthBar/HP +@onready var timer : Timer = $Timer func setHP(currentHp, maxHp): healthBar.min_value = 0 healthBar.max_value = maxHp healthBar.value = currentHp hpLabel.text = str(currentHp) + "/" + str(maxHp) + timer.start() + visible = true + + +func _on_timer_timeout(): + visible = false diff --git a/Scenes/Spawnables/UI/SpawnableUI.tscn b/Scenes/Spawnables/UI/SpawnableUI.tscn index 846d842..a75e5f9 100644 --- a/Scenes/Spawnables/UI/SpawnableUI.tscn +++ b/Scenes/Spawnables/UI/SpawnableUI.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=3 uid="uid://fojbwshce7ah"] +[gd_scene load_steps=3 format=3 uid="uid://fojbwshce7ah"] [ext_resource type="Script" path="res://Scenes/Spawnables/UI/SpawnableUI.gd" id="1_en1j6"] +[ext_resource type="Theme" uid="uid://dr1h7to56a2pv" path="res://Themes/base_theme.tres" id="2_ouwgg"] [node name="SpawnableUI" type="Control"] layout_mode = 3 @@ -18,6 +19,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("2_ouwgg") min_value = 100.0 step = 1.0 value = 100.0 @@ -36,7 +38,11 @@ offset_right = 15.5 offset_bottom = 7.5 grow_horizontal = 2 grow_vertical = 2 -theme_override_font_sizes/font_size = 8 text = "100/100" horizontal_alignment = 1 vertical_alignment = 1 + +[node name="Timer" type="Timer" parent="."] +one_shot = true + +[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/Scenes/Spawnables/template_spawnable.gd b/Scenes/Spawnables/template_spawnable.gd index 14af656..e919815 100644 --- a/Scenes/Spawnables/template_spawnable.gd +++ b/Scenes/Spawnables/template_spawnable.gd @@ -95,6 +95,7 @@ func receive_damage(dmg): spawnableUI.setHP(currentHp, maxHp) func die(): + enemy.remove_foe(self) bodyCollision.disabled = true damageCollision.disabled = true spawnableUI.visible = false @@ -103,7 +104,6 @@ func die(): animatedSprite.play("death") animatedSprite.disconnect("animation_finished", endAttack) animatedSprite.connect("animation_finished", fadeOut) - enemy.remove_foe(self) func fadeOut(): var tween = get_tree().create_tween() diff --git a/Scenes/Spawnables/template_spawnable.tscn b/Scenes/Spawnables/template_spawnable.tscn index aac09d9..dbf6447 100644 --- a/Scenes/Spawnables/template_spawnable.tscn +++ b/Scenes/Spawnables/template_spawnable.tscn @@ -232,8 +232,8 @@ height = 24.0 radius = 8.0 [node name="TemplateSpawnable" type="CharacterBody2D"] -collision_layer = 4 -collision_mask = 4 +collision_layer = 6 +collision_mask = 6 motion_mode = 1 script = ExtResource("1_rkej7") diff --git a/Scenes/enemy.tscn b/Scenes/enemy.tscn index 33e7b47..d0f801e 100644 --- a/Scenes/enemy.tscn +++ b/Scenes/enemy.tscn @@ -375,6 +375,7 @@ position = Vector2(10, 10) collision_layer = 5 collision_mask = 5 script = ExtResource("1_xj62t") +hp = 5 [node name="Sprite" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_dqf8u") diff --git a/Themes/base_theme.tres b/Themes/base_theme.tres new file mode 100644 index 0000000..a40d3eb --- /dev/null +++ b/Themes/base_theme.tres @@ -0,0 +1,14 @@ +[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dr1h7to56a2pv"] + +[ext_resource type="FontFile" uid="uid://01mccw37teq2" path="res://Assets/Fonts/alagard.ttf" id="1_i16b1"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hf10d"] +bg_color = Color(0.403922, 0.0117647, 0.0627451, 0.188235) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jy7e3"] +bg_color = Color(0.803922, 0.152941, 0.188235, 1) + +[resource] +Label/fonts/font = ExtResource("1_i16b1") +ProgressBar/styles/background = SubResource("StyleBoxFlat_hf10d") +ProgressBar/styles/fill = SubResource("StyleBoxFlat_jy7e3") diff --git a/project.godot b/project.godot index a9f8942..ea08dde 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,7 @@ config/icon="res://icon.svg" window/size/viewport_width=960 window/size/viewport_height=540 +window/size/mode=4 window/size/resizable=false window/stretch/mode="viewport" @@ -56,6 +57,11 @@ ui_down={ , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +place_spawnable={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) +] +} [rendering]