smaller map, eating apples, death

This commit is contained in:
Tabby 2025-08-15 13:33:08 +10:00
parent 8c0860a840
commit 2c512d5764
12 changed files with 152 additions and 13 deletions

15
prefabs/apple.tscn Normal file
View file

@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://qpjwodeafyno"]
[ext_resource type="Texture2D" uid="uid://dmmdu0ayhmlnk" path="res://assets/apple.png" id="1_sblxh"]
[sub_resource type="CircleShape2D" id="CircleShape2D_5v1qd"]
radius = 50.0
[node name="Apple" type="Area2D" groups=["apple"]]
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(10, 10)
texture = ExtResource("1_sblxh")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_5v1qd")

View file

@ -61,3 +61,13 @@ func become_fake():
#modulate = Color.DIM_GRAY
#collision_layer = 2
pass
func _on_eat_die_box_area_entered(area: Area2D) -> void:
if(area.is_in_group("apple")):
area.queue_free()
print("mmm tasty apple")
if(area.is_in_group("wall")):
print("i die")
get_tree().get_root().process_mode = Node.PROCESS_MODE_DISABLED

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://bwoeu7ask0fck"]
[gd_scene load_steps=8 format=3 uid="uid://bwoeu7ask0fck"]
[ext_resource type="Script" uid="uid://b5cqo12km1nh3" path="res://prefabs/snake_segment.gd" id="1_3ulhv"]
[ext_resource type="Texture2D" uid="uid://l8x3dp68yyxr" path="res://assets/segement.png" id="1_6uqch"]
@ -9,6 +9,9 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_08kyq"]
size = Vector2(8, 64)
[sub_resource type="CircleShape2D" id="CircleShape2D_08kyq"]
radius = 50.0
[node name="SnakeSegment" type="AnimatableBody2D" node_paths=PackedStringArray("door")]
script = ExtResource("1_3ulhv")
door = NodePath("DoorArm")
@ -49,3 +52,10 @@ shape = SubResource("RectangleShape2D_08kyq")
[node name="Sprite2D" type="Sprite2D" parent="DoorArm/Door"]
texture = ExtResource("4_34t3n")
[node name="EatDieBox" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="EatDieBox"]
shape = SubResource("CircleShape2D_08kyq")
[connection signal="area_entered" from="EatDieBox" to="." method="_on_eat_die_box_area_entered"]

9
prefabs/wall.tscn Normal file
View file

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://bl5py87o1qbgr"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_iy8pp"]
size = Vector2(6400, 320)
[node name="Wall" type="Area2D" groups=["wall"]]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_iy8pp")