Sidebar and lives
This commit is contained in:
@ -8,6 +8,8 @@ const COBOLD = preload("res://Game/Mobs/cobold.tscn")
|
|||||||
|
|
||||||
const enemies = [FORKMAN, COBOLD, ORK]
|
const enemies = [FORKMAN, COBOLD, ORK]
|
||||||
|
|
||||||
|
var lives = 20
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
spawnMonster()
|
spawnMonster()
|
||||||
|
|
||||||
@ -17,3 +19,10 @@ func spawnMonster():
|
|||||||
path.add_child(monster)
|
path.add_child(monster)
|
||||||
|
|
||||||
path_2d.add_child(path)
|
path_2d.add_child(path)
|
||||||
|
|
||||||
|
func decrease_life(damage) -> void:
|
||||||
|
lives -= damage
|
||||||
|
print(lives)
|
||||||
|
if lives == 0:
|
||||||
|
print("DEAD")
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=133 format=4 uid="uid://bgme05i7taycc"]
|
[gd_scene load_steps=134 format=4 uid="uid://bgme05i7taycc"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://f1npbjsw71nk" path="res://Assets/Tiles/Fields/FieldsTile_01.png" id="1_fdpq6"]
|
[ext_resource type="Texture2D" uid="uid://f1npbjsw71nk" path="res://Assets/Tiles/Fields/FieldsTile_01.png" id="1_fdpq6"]
|
||||||
[ext_resource type="Script" uid="uid://xo6vbicdva8d" path="res://Game/Maps/map_1.gd" id="1_rec5e"]
|
[ext_resource type="Script" uid="uid://xo6vbicdva8d" path="res://Game/Maps/map_1.gd" id="1_rec5e"]
|
||||||
@ -66,6 +66,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://5wec1pm5l10c" path="res://Assets/Tiles/Fields/FieldsTile_63.png" id="63_gsp4q"]
|
[ext_resource type="Texture2D" uid="uid://5wec1pm5l10c" path="res://Assets/Tiles/Fields/FieldsTile_63.png" id="63_gsp4q"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bof7eh3ttmi2f" path="res://Assets/Tiles/Fields/FieldsTile_64.png" id="64_5s0ky"]
|
[ext_resource type="Texture2D" uid="uid://bof7eh3ttmi2f" path="res://Assets/Tiles/Fields/FieldsTile_64.png" id="64_5s0ky"]
|
||||||
[ext_resource type="Texture2D" uid="uid://do3u4pgcgn7g3" path="res://Assets/Castles/Asset 27.png" id="65_ef8wx"]
|
[ext_resource type="Texture2D" uid="uid://do3u4pgcgn7g3" path="res://Assets/Castles/Asset 27.png" id="65_ef8wx"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ddn64i6logtw0" path="res://Game/sidepanel.tscn" id="67_rec5e"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_3uxyt"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_3uxyt"]
|
||||||
texture = ExtResource("1_fdpq6")
|
texture = ExtResource("1_fdpq6")
|
||||||
@ -474,7 +475,7 @@ tile_map_data = PackedByteArray("AAAAAAAAgAAAAAAAAAABAAAAgAAAAAAAAAACAAAAgAAAAAA
|
|||||||
tile_set = SubResource("TileSet_4e145")
|
tile_set = SubResource("TileSet_4e145")
|
||||||
rendering_quadrant_size = 64
|
rendering_quadrant_size = 64
|
||||||
|
|
||||||
[node name="Asset27" type="Sprite2D" parent="."]
|
[node name="Castle" type="Sprite2D" parent="."]
|
||||||
position = Vector2(1152, 448)
|
position = Vector2(1152, 448)
|
||||||
scale = Vector2(0.238927, 0.171569)
|
scale = Vector2(0.238927, 0.171569)
|
||||||
texture = ExtResource("65_ef8wx")
|
texture = ExtResource("65_ef8wx")
|
||||||
@ -486,4 +487,10 @@ curve = SubResource("Curve2D_6abe5")
|
|||||||
wait_time = 1.5
|
wait_time = 1.5
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
|
[node name="SidePanel" parent="." instance=ExtResource("67_rec5e")]
|
||||||
|
offset_left = -2.0
|
||||||
|
offset_top = 583.0
|
||||||
|
offset_right = 1152.0
|
||||||
|
offset_bottom = 647.0
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
|
@ -3,6 +3,7 @@ extends Node2D
|
|||||||
var speed = 0
|
var speed = 0
|
||||||
var health = 0
|
var health = 0
|
||||||
var shield = 0
|
var shield = 0
|
||||||
|
var damage = 0
|
||||||
|
|
||||||
var current_health = 0
|
var current_health = 0
|
||||||
var current_shield = 0
|
var current_shield = 0
|
||||||
@ -11,6 +12,7 @@ var last_position: Vector2 = Vector2.ZERO # To store the previous position
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
last_position = get_parent().position
|
last_position = get_parent().position
|
||||||
|
|
||||||
set_character_data()
|
set_character_data()
|
||||||
adjust_health_bar()
|
adjust_health_bar()
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ func move_character(delta: float) -> void:
|
|||||||
|
|
||||||
#if reached the end of the path remove both the path, and the character
|
#if reached the end of the path remove both the path, and the character
|
||||||
if path_follow.get_progress_ratio() >= 0.999:
|
if path_follow.get_progress_ratio() >= 0.999:
|
||||||
|
get_parent().get_parent().get_parent().decrease_life(damage)
|
||||||
get_parent().queue_free()
|
get_parent().queue_free()
|
||||||
|
|
||||||
|
|
||||||
@ -47,14 +50,17 @@ func set_character_data():
|
|||||||
speed = 120
|
speed = 120
|
||||||
health = 100
|
health = 100
|
||||||
shield = 100
|
shield = 100
|
||||||
|
damage = 2
|
||||||
"Ork":
|
"Ork":
|
||||||
speed = 80
|
speed = 80
|
||||||
health = 150
|
health = 150
|
||||||
shield = 100
|
shield = 100
|
||||||
|
damage = 5
|
||||||
"Cobold":
|
"Cobold":
|
||||||
speed = 200
|
speed = 200
|
||||||
health = 50
|
health = 50
|
||||||
shield = 0
|
shield = 0
|
||||||
|
damage = 1
|
||||||
|
|
||||||
get_node("CharacterBody2D/AnimatedSprite2D").speed_scale = float(speed) / 100 #adjust animation speed based on the character speed
|
get_node("CharacterBody2D/AnimatedSprite2D").speed_scale = float(speed) / 100 #adjust animation speed based on the character speed
|
||||||
current_health = health
|
current_health = health
|
||||||
|
4
Game/sidepanel.gd
Normal file
4
Game/sidepanel.gd
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
extends Panel
|
||||||
|
|
||||||
|
|
||||||
|
|
1
Game/sidepanel.gd.uid
Normal file
1
Game/sidepanel.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://c6sh5em844tx2
|
63
Game/sidepanel.tscn
Normal file
63
Game/sidepanel.tscn
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://ddn64i6logtw0"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c6sh5em844tx2" path="res://Game/sidepanel.gd" id="1_klyhg"]
|
||||||
|
|
||||||
|
[node name="SidePanel" type="Panel"]
|
||||||
|
custom_minimum_size = Vector2(0, 60)
|
||||||
|
anchors_preset = 12
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
size_flags_horizontal = 0
|
||||||
|
size_flags_vertical = 8
|
||||||
|
script = ExtResource("1_klyhg")
|
||||||
|
|
||||||
|
[node name="HBoxContainer4" type="HBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 120
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer4"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 120
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="HBoxContainer4/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Coins: "
|
||||||
|
|
||||||
|
[node name="HBoxContainer2" type="HBoxContainer" parent="HBoxContainer4"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 120
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Button2" type="Button" parent="HBoxContainer4/HBoxContainer2"]
|
||||||
|
custom_minimum_size = Vector2(120, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Archer"
|
||||||
|
|
||||||
|
[node name="Button3" type="Button" parent="HBoxContainer4/HBoxContainer2"]
|
||||||
|
custom_minimum_size = Vector2(120, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Wizard"
|
||||||
|
|
||||||
|
[node name="Button4" type="Button" parent="HBoxContainer4/HBoxContainer2"]
|
||||||
|
custom_minimum_size = Vector2(120, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Mortar"
|
||||||
|
|
||||||
|
[node name="HBoxContainer3" type="HBoxContainer" parent="HBoxContainer4"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 120
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="HBoxContainer4/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Lives: "
|
Reference in New Issue
Block a user