Skip to content

Commit 8573591

Browse files
The player should no longer spawn inside of structures
1 parent 2bb5250 commit 8573591

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

Scenes/Objects/Player.tscn

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[ext_resource type="Texture2D" uid="uid://vk7prp3tpig3" path="res://Assets/Textures/UI/progress_bar.png" id="4_w3k6v"]
88
[ext_resource type="Script" uid="uid://cy6otwbqa0w1x" path="res://Scripts/Other/hunger_and_thirst.gd" id="5_s8rx5"]
99
[ext_resource type="Script" uid="uid://dhie3qxe0hb7i" path="res://Scripts/player_animations.gd" id="7_vsrq0"]
10+
[ext_resource type="Script" uid="uid://ckekt4jyusoh" path="res://Scripts/Other/spawn_area_clear.gd" id="8_w3k6v"]
1011

1112
[sub_resource type="RectangleShape2D" id="RectangleShape2D_t86h6"]
1213
size = Vector2(96.66666, 93.33333)
@@ -174,6 +175,9 @@ _data = {
174175
&"walking": SubResource("Animation_d83tg")
175176
}
176177

178+
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vsrq0"]
179+
size = Vector2(256.66666, 256.66666)
180+
177181
[node name="Player" type="CharacterBody2D" unique_id=2146920496]
178182
z_index = 5
179183
texture_filter = 1
@@ -244,7 +248,6 @@ autoplay = &"pulse"
244248
script = ExtResource("5_s8rx5")
245249
hunger_per_second = 0.008
246250
thirst_per_second = 0.01
247-
thirst_per_second_running_multipliar = 10.0
248251

249252
[node name="Timer" type="Timer" parent="HungerAndThirst" unique_id=497556148]
250253
autostart = true
@@ -262,4 +265,14 @@ libraries/ = SubResource("AnimationLibrary_ff814")
262265

263266
[node name="AudioListener2D" type="AudioListener2D" parent="." unique_id=992318517]
264267

268+
[node name="SpawnAreaClear" type="Area2D" parent="." unique_id=855058091]
269+
collision_layer = 0
270+
collision_mask = 272
271+
script = ExtResource("8_w3k6v")
272+
273+
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpawnAreaClear" unique_id=1597975902]
274+
position = Vector2(1.6666666, -1.6666666)
275+
shape = SubResource("RectangleShape2D_vsrq0")
276+
debug_color = Color(0.6591337, 0.5090556, 0.23106265, 0.41960785)
277+
265278
[connection signal="timeout" from="HungerAndThirst/Timer" to="HungerAndThirst" method="_on_timer_timeout"]

Scripts/Other/spawn_area_clear.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extends Area2D
2+
3+
func clear_area() -> void:
4+
for body in get_overlapping_bodies():
5+
body.queue_free()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://ckekt4jyusoh

Scripts/Other/world_gen.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func choose_spawn_point() -> void:
7979
var pos = spawn_points_node.get_child(rand).global_position
8080
player.global_position = pos
8181
player.respawn_point = pos
82+
player.get_node("SpawnAreaClear").clear_area()
8283

8384
for child in spawn_points_node.get_children():
8485
child.queue_free()

0 commit comments

Comments
 (0)