slowed the snake down, now the doors are much more reliable
This commit is contained in:
parent
5197d10172
commit
7584cf0b19
11 changed files with 71 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cusdydgg4b1bo"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cusdydgg4b1bo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b48mlxrnte625" path="res://braincell.gd" id="1_q1ksn"]
|
||||
[ext_resource type="Texture2D" uid="uid://qyd5e7lb2esx" path="res://assets/braincell.png" id="2_wv6rk"]
|
||||
|
|
@ -6,7 +6,11 @@
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_g14j6"]
|
||||
radius = 16.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_q1ksn"]
|
||||
radius = 7.07107
|
||||
|
||||
[node name="Braincell" type="CharacterBody2D"]
|
||||
z_index = 15
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_q1ksn")
|
||||
|
||||
|
|
@ -15,3 +19,10 @@ texture = ExtResource("2_wv6rk")
|
|||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_g14j6")
|
||||
|
||||
[node name="doorBox" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="doorBox"]
|
||||
shape = SubResource("CircleShape2D_q1ksn")
|
||||
|
||||
[connection signal="area_entered" from="doorBox" to="." method="_on_door_box_area_entered"]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ extends Node2D
|
|||
|
||||
@export var this_seg : Node2D
|
||||
@export var prev_seg : Node2D
|
||||
@export var door_in_node : Node2D
|
||||
@export var door_out_node : Node2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ var want_direction : Vector2 = Vector2.RIGHT
|
|||
var start_pos : Vector2
|
||||
var target_pos : Vector2
|
||||
var move_progress : float
|
||||
var seg_id : int
|
||||
|
||||
var snake_speed : float = 1
|
||||
# if snake is the head, it chooses where it goes
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://cay1k1dp8yf12" path="res://assets/door.png" id="4_34t3n"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_08kyq"]
|
||||
size = Vector2(24, 64)
|
||||
size = Vector2(16, 64)
|
||||
|
||||
[node name="SnakeSegment" type="AnimatableBody2D" node_paths=PackedStringArray("door")]
|
||||
script = ExtResource("1_3ulhv")
|
||||
|
|
@ -22,27 +22,29 @@ script = ExtResource("2_3ulhv")
|
|||
radius = 160.0
|
||||
metadata/_custom_type_script = "uid://deq18nev0kwbg"
|
||||
|
||||
[node name="DoorArm" type="Node2D" parent="." node_paths=PackedStringArray("this_seg")]
|
||||
[node name="DoorArm" type="Node2D" parent="." node_paths=PackedStringArray("this_seg", "door_in_node", "door_out_node")]
|
||||
script = ExtResource("4_08kyq")
|
||||
this_seg = NodePath("..")
|
||||
door_in_node = NodePath("Door/DoorIn")
|
||||
door_out_node = NodePath("Door/DoorOut")
|
||||
|
||||
[node name="Door" type="Node2D" parent="DoorArm"]
|
||||
z_index = 11
|
||||
position = Vector2(160, 0)
|
||||
scale = Vector2(1, 1)
|
||||
|
||||
[node name="DoorIn" type="Area2D" parent="DoorArm/Door"]
|
||||
position = Vector2(-16, 0)
|
||||
position = Vector2(-22, 0)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArm/Door/DoorIn"]
|
||||
position = Vector2(32, 0)
|
||||
position = Vector2(14, 0)
|
||||
shape = SubResource("RectangleShape2D_08kyq")
|
||||
|
||||
[node name="DoorOut" type="Area2D" parent="DoorArm/Door"]
|
||||
position = Vector2(16, 0)
|
||||
position = Vector2(22, 0)
|
||||
rotation = 3.14159
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArm/Door/DoorOut"]
|
||||
position = Vector2(32, 0)
|
||||
position = Vector2(14, 3.54925e-05)
|
||||
shape = SubResource("RectangleShape2D_08kyq")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="DoorArm/Door"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue