Merge branch 'main' of https://gamejam.fachschaft.info/Florian/The_Dark_Side_of_Earth
This commit is contained in:
commit
c67eec8e05
15 changed files with 126 additions and 14 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://djawvtdwp423v"]
|
[gd_scene load_steps=6 format=3 uid="uid://djawvtdwp423v"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b2ji03ekijjnn" path="res://building.gd" id="1_5j34s"]
|
[ext_resource type="Script" uid="uid://b2ji03ekijjnn" path="res://buildings/building.gd" id="1_5j34s"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_2yopf"]
|
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_2yopf"]
|
||||||
[ext_resource type="Shader" uid="uid://c7gb1nqwvkr37" path="res://building.gdshader" id="2_f1gjg"]
|
[ext_resource type="Shader" uid="uid://c7gb1nqwvkr37" path="res://buildings/building.gdshader" id="2_f1gjg"]
|
||||||
[ext_resource type="Script" uid="uid://dj7d4d2xs3nci" path="res://building_mesh.gd" id="4_qnfc1"]
|
[ext_resource type="Script" uid="uid://dj7d4d2xs3nci" path="res://buildings/building_mesh.gd" id="4_qnfc1"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qnfc1"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qnfc1"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,4 @@ extends Sprite2D
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var location = Vector2i(get_parent().location)
|
var location = Vector2i(get_parent().location)
|
||||||
var dimension = Vector2i(get_parent().dimension)
|
var dimension = Vector2i(get_parent().dimension)
|
||||||
print(location, dimension)
|
|
||||||
self_modulate = Color8(location.x, location.y, dimension.x, dimension.y)
|
self_modulate = Color8(location.x, location.y, dimension.x, dimension.y)
|
||||||
|
|
|
||||||
21
healthbar/healthbar.gd
Normal file
21
healthbar/healthbar.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
extends HBoxContainer
|
||||||
|
|
||||||
|
@export var initial_health : int = 5
|
||||||
|
@export var packedHeart : PackedScene;
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
for i in range(initial_health):
|
||||||
|
add_child(packedHeart.instantiate())
|
||||||
|
|
||||||
|
func set_health(health : int):
|
||||||
|
var i = 0
|
||||||
|
for heart : Heart in get_children():
|
||||||
|
i += 1
|
||||||
|
if i <= health:
|
||||||
|
heart.restore()
|
||||||
|
else:
|
||||||
|
heart.fade()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_health_changed(new_health: int) -> void:
|
||||||
|
set_health(new_health)
|
||||||
1
healthbar/healthbar.gd.uid
Normal file
1
healthbar/healthbar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b3fncqgyodcjc
|
||||||
11
healthbar/healthbar.tscn
Normal file
11
healthbar/healthbar.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cjsrtswk4vgf2"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://b3fncqgyodcjc" path="res://healthbar/healthbar.gd" id="1_ubhit"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://em0xambhywfv" path="res://healthbar/heart.tscn" id="2_y66kq"]
|
||||||
|
|
||||||
|
[node name="Healthbar" type="HBoxContainer"]
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
tooltip_text = "This shows your health. If you lose it all, you die."
|
||||||
|
script = ExtResource("1_ubhit")
|
||||||
|
packedHeart = ExtResource("2_y66kq")
|
||||||
12
healthbar/heart.gd
Normal file
12
healthbar/heart.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
class_name Heart extends MarginContainer
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
restore()
|
||||||
|
|
||||||
|
func restore():
|
||||||
|
$UP.visible = true
|
||||||
|
$DOWN.visible = false
|
||||||
|
|
||||||
|
func fade():
|
||||||
|
$UP.visible = false
|
||||||
|
$DOWN.visible = true
|
||||||
1
healthbar/heart.gd.uid
Normal file
1
healthbar/heart.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c60wm212fu1ti
|
||||||
16
healthbar/heart.tscn
Normal file
16
healthbar/heart.tscn
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://em0xambhywfv"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c60wm212fu1ti" path="res://healthbar/heart.gd" id="1_c17c5"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_kepki"]
|
||||||
|
|
||||||
|
[node name="Heart" type="MarginContainer"]
|
||||||
|
script = ExtResource("1_c17c5")
|
||||||
|
|
||||||
|
[node name="UP" type="TextureRect" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("1_kepki")
|
||||||
|
|
||||||
|
[node name="DOWN" type="TextureRect" parent="."]
|
||||||
|
modulate = Color(0.03137255, 0.21568628, 0.28627452, 1)
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("1_kepki")
|
||||||
21
main.tscn
21
main.tscn
|
|
@ -1,20 +1,39 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://cxo6bq26huau7"]
|
[gd_scene load_steps=7 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="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="3_h2yge"]
|
[ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="3_h2yge"]
|
||||||
[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://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"]
|
||||||
|
|
||||||
[node name="main" type="Node2D"]
|
[node name="main" type="Node2D"]
|
||||||
|
|
||||||
[node name="Earth" parent="." instance=ExtResource("3_lquwl")]
|
[node name="Earth" parent="." instance=ExtResource("3_lquwl")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("2_lquwl")
|
||||||
|
|
||||||
[node name="Ghost" parent="." instance=ExtResource("3_h2yge")]
|
[node name="Ghost" parent="." instance=ExtResource("3_h2yge")]
|
||||||
position = Vector2(0, -3200)
|
position = Vector2(0, -3200)
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("2_1bvp3")]
|
[node name="Player" parent="." instance=ExtResource("2_1bvp3")]
|
||||||
|
unique_name_in_owner = true
|
||||||
position = Vector2(500, -3100)
|
position = Vector2(500, -3100)
|
||||||
scale = Vector2(3, 3)
|
scale = Vector2(3, 3)
|
||||||
|
|
||||||
[node name="Building Generator" type="Node" parent="."]
|
[node name="Building Generator" type="Node" parent="."]
|
||||||
script = ExtResource("4_1bvp3")
|
script = ExtResource("4_1bvp3")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="Building Generator"]
|
||||||
|
wait_time = 5.0
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="Healthbar" parent="CanvasLayer" instance=ExtResource("6_7mycd")]
|
||||||
|
offset_right = 128.0
|
||||||
|
offset_bottom = 128.0
|
||||||
|
|
||||||
|
[connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"]
|
||||||
|
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,12 @@ var air_jumps_max = 1;
|
||||||
var air_jumps_current = 1;
|
var air_jumps_current = 1;
|
||||||
|
|
||||||
# HP and Iframes
|
# HP and Iframes
|
||||||
var current_hp = 5;
|
signal health_changed(new_health : int)
|
||||||
|
|
||||||
|
var current_hp = 5:
|
||||||
|
set(new_hp):
|
||||||
|
current_hp = new_hp
|
||||||
|
health_changed.emit(current_hp)
|
||||||
var max_hp = 5;
|
var max_hp = 5;
|
||||||
var hit_invulnerability = 0.5
|
var hit_invulnerability = 0.5
|
||||||
var inv_time = 0;
|
var inv_time = 0;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,22 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
@onready var grid : Grid = %Earth.get_grid()
|
||||||
|
|
||||||
|
func random_oppostite_collumn() -> int:
|
||||||
|
var playerpos = %Player.position
|
||||||
|
var player_angle = atan2(playerpos.y, playerpos.x)
|
||||||
|
|
||||||
|
var offset = randf_range(TAU/3, 2*TAU/3)
|
||||||
|
var spawn_angle = player_angle + offset
|
||||||
|
var collumn = int(spawn_angle / TAU * grid.num_collumns + grid.num_collumns) % grid.num_collumns
|
||||||
|
|
||||||
|
return collumn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
var collumn = random_oppostite_collumn()
|
||||||
|
var building : Building = grid.packed_buildings[0].instantiate()
|
||||||
|
grid.add_building_to_collumn(building, collumn)
|
||||||
|
|
||||||
|
|
|
||||||
4
world/earth.gd
Normal file
4
world/earth.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
func get_grid() -> Grid:
|
||||||
|
return $Grid
|
||||||
1
world/earth.gd.uid
Normal file
1
world/earth.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://vgxh2xdevat7
|
||||||
|
|
@ -19,6 +19,7 @@ script = ExtResource("2_2bhor")
|
||||||
radius = 3000.0
|
radius = 3000.0
|
||||||
|
|
||||||
[node name="Grid" type="Node2D" parent="."]
|
[node name="Grid" type="Node2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
script = ExtResource("3_2bhor")
|
script = ExtResource("3_2bhor")
|
||||||
ground_radius = 3000.0
|
ground_radius = 3000.0
|
||||||
cell_height = 300.0
|
cell_height = 300.0
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,11 @@ func add_building_to_collumn(building : Building, collumn : int):
|
||||||
add_child(building)
|
add_child(building)
|
||||||
|
|
||||||
# for testing
|
# for testing
|
||||||
func _ready() -> void:
|
#func _ready() -> void:
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
for i in range(100):
|
#for i in range(100):
|
||||||
var test_building = packed_buildings[0].instantiate()
|
#var test_building = packed_buildings[0].instantiate()
|
||||||
var collumn = randi() % 60
|
#var collumn = randi() % 60
|
||||||
add_building_to_collumn(test_building, collumn)
|
#add_building_to_collumn(test_building, collumn)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue