spawnable tests and hpbar for bebittes
This commit is contained in:
parent
d518691cea
commit
660c13980f
BIN
Assets/Fonts/alagard.ttf
Normal file
BIN
Assets/Fonts/alagard.ttf
Normal file
Binary file not shown.
38
Assets/Fonts/alagard.ttf.import
Normal file
38
Assets/Fonts/alagard.ttf.import
Normal file
@ -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={}
|
@ -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://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" 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_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"]
|
[node name="Level1" type="Node2D"]
|
||||||
|
|
||||||
@ -33,3 +35,8 @@ position = Vector2(528, 224)
|
|||||||
|
|
||||||
[node name="Candle4" parent="Decor" instance=ExtResource("2_5hdq4")]
|
[node name="Candle4" parent="Decor" instance=ExtResource("2_5hdq4")]
|
||||||
position = Vector2(528, 320)
|
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")]
|
||||||
|
@ -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://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://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"]
|
[node name="Level1" type="Node2D"]
|
||||||
|
|
||||||
@ -13,14 +13,4 @@
|
|||||||
[node name="Enemy" parent="." instance=ExtResource("2_ftshv")]
|
[node name="Enemy" parent="." instance=ExtResource("2_ftshv")]
|
||||||
position = Vector2(497, 324)
|
position = Vector2(497, 324)
|
||||||
|
|
||||||
[node name="BatSpawnable" parent="." instance=ExtResource("3_a1ucf")]
|
[node name="Player" parent="." instance=ExtResource("4_dvauv")]
|
||||||
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
|
|
||||||
|
16
Scenes/Player/player.gd
Normal file
16
Scenes/Player/player.gd
Normal file
@ -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)
|
8
Scenes/Player/player.tscn
Normal file
8
Scenes/Player/player.tscn
Normal file
@ -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")
|
@ -2,9 +2,16 @@ extends Control
|
|||||||
|
|
||||||
@onready var healthBar : ProgressBar = $HealthBar
|
@onready var healthBar : ProgressBar = $HealthBar
|
||||||
@onready var hpLabel : Label = $HealthBar/HP
|
@onready var hpLabel : Label = $HealthBar/HP
|
||||||
|
@onready var timer : Timer = $Timer
|
||||||
|
|
||||||
func setHP(currentHp, maxHp):
|
func setHP(currentHp, maxHp):
|
||||||
healthBar.min_value = 0
|
healthBar.min_value = 0
|
||||||
healthBar.max_value = maxHp
|
healthBar.max_value = maxHp
|
||||||
healthBar.value = currentHp
|
healthBar.value = currentHp
|
||||||
hpLabel.text = str(currentHp) + "/" + str(maxHp)
|
hpLabel.text = str(currentHp) + "/" + str(maxHp)
|
||||||
|
timer.start()
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
visible = false
|
||||||
|
@ -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="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"]
|
[node name="SpawnableUI" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@ -18,6 +19,7 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
theme = ExtResource("2_ouwgg")
|
||||||
min_value = 100.0
|
min_value = 100.0
|
||||||
step = 1.0
|
step = 1.0
|
||||||
value = 100.0
|
value = 100.0
|
||||||
@ -36,7 +38,11 @@ offset_right = 15.5
|
|||||||
offset_bottom = 7.5
|
offset_bottom = 7.5
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme_override_font_sizes/font_size = 8
|
|
||||||
text = "100/100"
|
text = "100/100"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
|
@ -95,6 +95,7 @@ func receive_damage(dmg):
|
|||||||
spawnableUI.setHP(currentHp, maxHp)
|
spawnableUI.setHP(currentHp, maxHp)
|
||||||
|
|
||||||
func die():
|
func die():
|
||||||
|
enemy.remove_foe(self)
|
||||||
bodyCollision.disabled = true
|
bodyCollision.disabled = true
|
||||||
damageCollision.disabled = true
|
damageCollision.disabled = true
|
||||||
spawnableUI.visible = false
|
spawnableUI.visible = false
|
||||||
@ -103,7 +104,6 @@ func die():
|
|||||||
animatedSprite.play("death")
|
animatedSprite.play("death")
|
||||||
animatedSprite.disconnect("animation_finished", endAttack)
|
animatedSprite.disconnect("animation_finished", endAttack)
|
||||||
animatedSprite.connect("animation_finished", fadeOut)
|
animatedSprite.connect("animation_finished", fadeOut)
|
||||||
enemy.remove_foe(self)
|
|
||||||
|
|
||||||
func fadeOut():
|
func fadeOut():
|
||||||
var tween = get_tree().create_tween()
|
var tween = get_tree().create_tween()
|
||||||
|
@ -232,8 +232,8 @@ height = 24.0
|
|||||||
radius = 8.0
|
radius = 8.0
|
||||||
|
|
||||||
[node name="TemplateSpawnable" type="CharacterBody2D"]
|
[node name="TemplateSpawnable" type="CharacterBody2D"]
|
||||||
collision_layer = 4
|
collision_layer = 6
|
||||||
collision_mask = 4
|
collision_mask = 6
|
||||||
motion_mode = 1
|
motion_mode = 1
|
||||||
script = ExtResource("1_rkej7")
|
script = ExtResource("1_rkej7")
|
||||||
|
|
||||||
|
@ -375,6 +375,7 @@ position = Vector2(10, 10)
|
|||||||
collision_layer = 5
|
collision_layer = 5
|
||||||
collision_mask = 5
|
collision_mask = 5
|
||||||
script = ExtResource("1_xj62t")
|
script = ExtResource("1_xj62t")
|
||||||
|
hp = 5
|
||||||
|
|
||||||
[node name="Sprite" type="AnimatedSprite2D" parent="."]
|
[node name="Sprite" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_dqf8u")
|
sprite_frames = SubResource("SpriteFrames_dqf8u")
|
||||||
|
14
Themes/base_theme.tres
Normal file
14
Themes/base_theme.tres
Normal file
@ -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")
|
@ -19,6 +19,7 @@ config/icon="res://icon.svg"
|
|||||||
|
|
||||||
window/size/viewport_width=960
|
window/size/viewport_width=960
|
||||||
window/size/viewport_height=540
|
window/size/viewport_height=540
|
||||||
|
window/size/mode=4
|
||||||
window/size/resizable=false
|
window/size/resizable=false
|
||||||
window/stretch/mode="viewport"
|
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)
|
, 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]
|
[rendering]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user