This commit is contained in:
RealMelwei 2025-09-17 18:25:58 +02:00
commit eefd58da42
6 changed files with 32 additions and 9 deletions

View file

@ -25,7 +25,7 @@ shape = SubResource("CircleShape2D_6attn")
texture = ExtResource("3_34o1m") texture = ExtResource("3_34o1m")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(6, 6) scale = Vector2(5, 5)
shape = SubResource("CircleShape2D_6attn") shape = SubResource("CircleShape2D_6attn")
[node name="EarthAligner" parent="." instance=ExtResource("3_obmiq")] [node name="EarthAligner" parent="." instance=ExtResource("3_obmiq")]

View file

@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://73g8y37skebh" path="res://item_ui/item_ui.tscn" id="6_4c57u"] [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://bbpf28ohayd8n" path="res://items/permanent_items/backslash.tscn" id="8_5vw27"] [ext_resource type="Script" uid="uid://3k6r3jnko4hg" path="res://show_fps.gd" id="8_5vw27"]
[node name="main" type="Node2D"] [node name="main" type="Node2D"]
@ -30,9 +30,10 @@ zoom = Vector2(0.12, 0.12)
[node name="Building Generator" type="Node" parent="."] [node name="Building Generator" type="Node" parent="."]
script = ExtResource("4_1bvp3") script = ExtResource("4_1bvp3")
initial_buildings = 10
[node name="Timer" type="Timer" parent="Building Generator"] [node name="Timer" type="Timer" parent="Building Generator"]
wait_time = 0.8 wait_time = 2.5
autostart = true autostart = true
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
@ -47,8 +48,14 @@ player = NodePath("../../Player")
[node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")] [node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")]
visible = false visible = false
[node name="Backslash" parent="." instance=ExtResource("8_5vw27")] [node name="FPS" type="Label" parent="CanvasLayer"]
position = Vector2(174, -3243) anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -40.0
offset_bottom = 23.0
grow_horizontal = 0
script = ExtResource("8_5vw27")
[connection signal="active_item_changed" from="Player" to="CanvasLayer/ItemUI" method="_on_player_active_item_changed"] [connection signal="active_item_changed" from="Player" to="CanvasLayer/ItemUI" method="_on_player_active_item_changed"]
[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"]

View file

@ -24,7 +24,7 @@ script = ExtResource("1_hv1tj")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-13, 5) position = Vector2(-13, 5)
rotation = 1.5708 rotation = 1.5708
scale = Vector2(-0.3, -0.9) scale = Vector2(-0.417, -0.985)
shape = SubResource("CapsuleShape2D_e4ynd") shape = SubResource("CapsuleShape2D_e4ynd")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]

4
show_fps.gd Normal file
View file

@ -0,0 +1,4 @@
extends Label
func _process(_delta):
set_text("FPS " + str(Engine.get_frames_per_second()))

1
show_fps.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://3k6r3jnko4hg

View file

@ -1,6 +1,7 @@
extends Node extends Node
@onready var grid : Grid = %Earth.get_grid() @onready var grid : Grid = %Earth.get_grid()
@export var initial_buildings : int;
func random_oppostite_collumn() -> int: func random_oppostite_collumn() -> int:
var playerpos = %Player.position var playerpos = %Player.position
@ -12,12 +13,22 @@ func random_oppostite_collumn() -> int:
return collumn return collumn
func random_collumn() -> int:
return randi_range(0, grid.num_collumns - 1)
func _ready():
for i in range(initial_buildings):
var collumn = random_collumn()
if 43 <= collumn and collumn <= 49:
continue
var building = randomize_building()
grid.add_building_to_collumn(building, collumn)
func _on_timer_timeout() -> void: func _on_timer_timeout() -> void:
var collumn = random_oppostite_collumn() var collumn = random_oppostite_collumn()
var index = randi() % 2 var building : Building = randomize_building()
var building : Building = grid.packed_buildings[index].instantiate()
grid.add_building_to_collumn(building, collumn) grid.add_building_to_collumn(building, collumn)
func randomize_building() -> Building:
var index = randi() % grid.packed_buildings.size()
return grid.packed_buildings[index].instantiate()