Merge branch 'main' of https://gamejam.fachschaft.info/Florian/The_Dark_Side_of_Earth
This commit is contained in:
commit
8c6f4ec327
5 changed files with 78 additions and 6 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
extends HBoxContainer
|
extends HBoxContainer
|
||||||
|
|
||||||
@export var initial_health : int = 5
|
|
||||||
@export var packedHeart : PackedScene;
|
@export var packedHeart : PackedScene;
|
||||||
|
var current_max_hp = 0
|
||||||
|
var current_health = 0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
for i in range(initial_health):
|
#for i in range(initial_health):
|
||||||
add_child(packedHeart.instantiate())
|
#add_child(packedHeart.instantiate())
|
||||||
|
pass
|
||||||
|
|
||||||
func set_health(health : int):
|
func set_health(health : int):
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
@ -15,7 +17,27 @@ func set_health(health : int):
|
||||||
heart.restore()
|
heart.restore()
|
||||||
else:
|
else:
|
||||||
heart.fade()
|
heart.fade()
|
||||||
|
current_health = health
|
||||||
|
|
||||||
|
func set_maxhealth(new_max_hp : int):
|
||||||
|
if new_max_hp > current_max_hp:
|
||||||
|
for i in range(new_max_hp - current_max_hp):
|
||||||
|
add_child(packedHeart.instantiate())
|
||||||
|
elif new_max_hp < current_max_hp:
|
||||||
|
var children = get_children()
|
||||||
|
for i in range(children.size()):
|
||||||
|
if new_max_hp < i+1:
|
||||||
|
children[i].queue_free()
|
||||||
|
current_health = min(current_health, current_max_hp)
|
||||||
|
else: pass
|
||||||
|
|
||||||
|
current_max_hp = new_max_hp
|
||||||
|
set_health(current_max_hp)
|
||||||
|
|
||||||
|
|
||||||
func _on_player_health_changed(new_health: int) -> void:
|
func _on_player_health_changed(new_health: int) -> void:
|
||||||
set_health(new_health)
|
set_health(new_health)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_max_hp_changed(new_max_hp: int) -> void:
|
||||||
|
set_maxhealth(new_max_hp)
|
||||||
|
|
|
||||||
37
item_ui/item_ui.tscn
Normal file
37
item_ui/item_ui.tscn
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://73g8y37skebh"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_lfuq2"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8oq0s"]
|
||||||
|
draw_center = false
|
||||||
|
border_width_left = 5
|
||||||
|
border_width_top = 5
|
||||||
|
border_width_right = 5
|
||||||
|
border_width_bottom = 5
|
||||||
|
border_color = Color(0, 0, 0, 0.69411767)
|
||||||
|
border_blend = true
|
||||||
|
corner_radius_top_left = 50
|
||||||
|
corner_radius_top_right = 50
|
||||||
|
corner_radius_bottom_right = 50
|
||||||
|
corner_radius_bottom_left = 50
|
||||||
|
|
||||||
|
[node name="ItemUI" type="MarginContainer"]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -150.0
|
||||||
|
offset_bottom = 150.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
theme_override_constants/margin_left = 25
|
||||||
|
theme_override_constants/margin_top = 25
|
||||||
|
theme_override_constants/margin_right = 25
|
||||||
|
theme_override_constants/margin_bottom = 25
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_8oq0s")
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("1_lfuq2")
|
||||||
|
expand_mode = 1
|
||||||
|
|
@ -31,6 +31,7 @@ func _ready():
|
||||||
var pool = choose_pool()
|
var pool = choose_pool()
|
||||||
var index = randi_range(0, pool.size() - 1)
|
var index = randi_range(0, pool.size() - 1)
|
||||||
var packed_scene : PackedScene = pool[index]
|
var packed_scene : PackedScene = pool[index]
|
||||||
|
if remove_after_spawn:
|
||||||
pool.remove_at(index)
|
pool.remove_at(index)
|
||||||
var object = packed_scene.instantiate()
|
var object = packed_scene.instantiate()
|
||||||
add_child.call_deferred(object)
|
add_child.call_deferred(object)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
[gd_scene load_steps=12 format=3 uid="uid://cxo6bq26huau7"]
|
[gd_scene load_steps=13 format=3 uid="uid://cxo6bq26huau7"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
|
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
|
||||||
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"]
|
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="3_lquwl"]
|
[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="3_lquwl"]
|
||||||
[ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"]
|
[ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://73g8y37skebh" path="res://item_ui/item_ui.tscn" id="6_4c57u"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"]
|
[ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"]
|
[ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"]
|
||||||
[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://utils/platform.tscn" id="7_272bh"]
|
[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://utils/platform.tscn" id="7_272bh"]
|
||||||
|
|
@ -44,6 +45,8 @@ autostart = true
|
||||||
offset_right = 128.0
|
offset_right = 128.0
|
||||||
offset_bottom = 128.0
|
offset_bottom = 128.0
|
||||||
|
|
||||||
|
[node name="ItemUI" parent="CanvasLayer" instance=ExtResource("6_4c57u")]
|
||||||
|
|
||||||
[node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")]
|
[node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
|
|
@ -64,6 +67,7 @@ position = Vector2(200, -3100)
|
||||||
position = Vector2(0, -3100)
|
position = Vector2(0, -3100)
|
||||||
|
|
||||||
[connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"]
|
[connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"]
|
||||||
|
[connection signal="max_hp_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_max_hp_changed"]
|
||||||
[connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"]
|
[connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"]
|
||||||
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
|
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
|
||||||
[connection signal="visibility_changed" from="CanvasLayer/DeathScreen" to="Player" method="_on_death_screen_visibility_changed"]
|
[connection signal="visibility_changed" from="CanvasLayer/DeathScreen" to="Player" method="_on_death_screen_visibility_changed"]
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,17 @@ var air_jumps_current = 1;
|
||||||
|
|
||||||
# HP and Iframes
|
# HP and Iframes
|
||||||
signal health_changed(new_health : int)
|
signal health_changed(new_health : int)
|
||||||
|
signal max_hp_changed(new_max_hp : int)
|
||||||
signal player_died
|
signal player_died
|
||||||
|
|
||||||
var current_hp = 5:
|
var current_hp = 5:
|
||||||
set(new_hp):
|
set(new_hp):
|
||||||
current_hp = new_hp
|
current_hp = new_hp
|
||||||
health_changed.emit(current_hp)
|
health_changed.emit(current_hp)
|
||||||
var max_hp = 5;
|
var max_hp = 5:
|
||||||
|
set(new_max_hp):
|
||||||
|
max_hp = new_max_hp
|
||||||
|
max_hp_changed.emit(max_hp)
|
||||||
var hit_invulnerability = 0.5
|
var hit_invulnerability = 0.5
|
||||||
var inv_time = 0;
|
var inv_time = 0;
|
||||||
var dead = false;
|
var dead = false;
|
||||||
|
|
@ -46,6 +50,10 @@ var atk_timer = 0
|
||||||
var active_item = null
|
var active_item = null
|
||||||
var item_cooldown = 0
|
var item_cooldown = 0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
max_hp_changed.emit(max_hp)
|
||||||
|
health_changed.emit(current_hp)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
manage_iframes(delta)
|
manage_iframes(delta)
|
||||||
manage_movement_options()
|
manage_movement_options()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue