need to sleep
This commit is contained in:
parent
dafae35985
commit
211a5e074b
13 changed files with 381 additions and 15 deletions
31
apple_furnace_man.gd
Normal file
31
apple_furnace_man.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var snake_man : Node2D
|
||||||
|
@export var count : Label
|
||||||
|
@export var my_area : Area2D
|
||||||
|
@export var brain : Node2D
|
||||||
|
var player_detected : bool
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
count.text = str( ceilf(snake_man.burn_apples*10)/10 )
|
||||||
|
if my_area.get_overlapping_areas():
|
||||||
|
player_detected = false
|
||||||
|
for overlaps in my_area.get_overlapping_areas():
|
||||||
|
if overlaps.is_in_group("braincell"):
|
||||||
|
player_detected = true
|
||||||
|
if player_detected:
|
||||||
|
modulate = Color.GREEN
|
||||||
|
else:
|
||||||
|
modulate = Color.WHITE
|
||||||
|
|
||||||
|
|
||||||
|
#print(str(player_detected) + " "+ str(snake_man.pit_apples) +" " +str(brain.holding_apple))
|
||||||
|
if player_detected and brain.holding_apple:
|
||||||
|
if Input.is_action_just_pressed("action"):
|
||||||
|
Router.burn_apple.emit()
|
||||||
1
apple_furnace_man.gd.uid
Normal file
1
apple_furnace_man.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dib0u5gw356nv
|
||||||
|
|
@ -2,6 +2,9 @@ extends Node2D
|
||||||
|
|
||||||
@export var snake_man : Node2D
|
@export var snake_man : Node2D
|
||||||
@export var count : Label
|
@export var count : Label
|
||||||
|
@export var my_area : Area2D
|
||||||
|
@export var brain : Node2D
|
||||||
|
var player_detected : bool
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
@ -11,3 +14,18 @@ func _ready() -> void:
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
count.text = str(snake_man.pit_apples)
|
count.text = str(snake_man.pit_apples)
|
||||||
|
if my_area.get_overlapping_areas():
|
||||||
|
player_detected = false
|
||||||
|
for overlaps in my_area.get_overlapping_areas():
|
||||||
|
if overlaps.is_in_group("braincell"):
|
||||||
|
player_detected = true
|
||||||
|
if player_detected:
|
||||||
|
modulate = Color.GREEN
|
||||||
|
else:
|
||||||
|
modulate = Color.WHITE
|
||||||
|
|
||||||
|
|
||||||
|
#print(str(player_detected) + " "+ str(snake_man.pit_apples) +" " +str(brain.holding_apple))
|
||||||
|
if player_detected and snake_man.pit_apples > 0 and not brain.holding_apple:
|
||||||
|
if Input.is_action_just_pressed("action"):
|
||||||
|
Router.pickup_apple.emit()
|
||||||
|
|
|
||||||
14
braincell.gd
14
braincell.gd
|
|
@ -8,6 +8,9 @@ var ready_to_door : bool = true
|
||||||
@export var hand : Node2D
|
@export var hand : Node2D
|
||||||
var holding_apple : bool = false
|
var holding_apple : bool = false
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
Router.pickup_apple.connect(grab)
|
||||||
|
Router.burn_apple.connect(drop)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
|
|
@ -29,14 +32,21 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
if !doorBox.has_overlapping_areas():
|
var door_detected :bool = false
|
||||||
|
for area in doorBox.get_overlapping_areas():
|
||||||
|
if area.name == "DoorIn" or area.name == "DoorOut":
|
||||||
|
door_detected = true
|
||||||
|
if !door_detected:
|
||||||
ready_to_door = true
|
ready_to_door = true
|
||||||
|
|
||||||
|
#if !doorBox.has_overlapping_areas():
|
||||||
|
#ready_to_door = true
|
||||||
|
|
||||||
hand.visible = holding_apple
|
hand.visible = holding_apple
|
||||||
|
|
||||||
|
|
||||||
func _on_door_box_area_entered(area: Area2D) -> void:
|
func _on_door_box_area_entered(area: Area2D) -> void:
|
||||||
print(area.name)
|
print(area.name + str(ready_to_door))
|
||||||
if ready_to_door:
|
if ready_to_door:
|
||||||
if area.name == "DoorIn":
|
if area.name == "DoorIn":
|
||||||
global_position = area.get_parent().get_parent().door_out_node.global_position
|
global_position = area.get_parent().get_parent().door_out_node.global_position
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ radius = 16.0
|
||||||
radius = 7.07107
|
radius = 7.07107
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_wv6rk"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_wv6rk"]
|
||||||
radius = 32.0
|
radius = 16.0
|
||||||
|
|
||||||
[node name="Braincell" type="CharacterBody2D" node_paths=PackedStringArray("doorBox", "hand")]
|
[node name="Braincell" type="CharacterBody2D" node_paths=PackedStringArray("doorBox", "hand")]
|
||||||
z_index = 15
|
z_index = 15
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ func _ready() -> void:
|
||||||
start_pos = position
|
start_pos = position
|
||||||
get_new_target()
|
get_new_target()
|
||||||
become_real()
|
become_real()
|
||||||
|
if door_disabled:
|
||||||
|
door.process_mode =Node.PROCESS_MODE_DISABLED
|
||||||
|
door.hide()
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://cay1k1dp8yf12" path="res://assets/door.png" id="4_34t3n"]
|
[ext_resource type="Texture2D" uid="uid://cay1k1dp8yf12" path="res://assets/door.png" id="4_34t3n"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_08kyq"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_08kyq"]
|
||||||
size = Vector2(8, 64)
|
size = Vector2(16, 64)
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_08kyq"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_08kyq"]
|
||||||
radius = 50.0
|
radius = 50.0
|
||||||
|
|
@ -38,7 +38,7 @@ position = Vector2(160, 0)
|
||||||
position = Vector2(-22, 0)
|
position = Vector2(-22, 0)
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArm/Door/DoorIn"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArm/Door/DoorIn"]
|
||||||
position = Vector2(10, 0)
|
position = Vector2(6, 0)
|
||||||
shape = SubResource("RectangleShape2D_08kyq")
|
shape = SubResource("RectangleShape2D_08kyq")
|
||||||
|
|
||||||
[node name="DoorOut" type="Area2D" parent="DoorArm/Door"]
|
[node name="DoorOut" type="Area2D" parent="DoorArm/Door"]
|
||||||
|
|
@ -46,7 +46,7 @@ position = Vector2(22, 0)
|
||||||
rotation = 3.14159
|
rotation = 3.14159
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArm/Door/DoorOut"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArm/Door/DoorOut"]
|
||||||
position = Vector2(10, 2.53518e-05)
|
position = Vector2(6, 1.52111e-05)
|
||||||
shape = SubResource("RectangleShape2D_08kyq")
|
shape = SubResource("RectangleShape2D_08kyq")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="DoorArm/Door"]
|
[node name="Sprite2D" type="Sprite2D" parent="DoorArm/Door"]
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ test_add_segment={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194445,"key_label":0,"unicode":55,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194445,"key_label":0,"unicode":55,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
action={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ extends Node
|
||||||
signal activate_seg(int)
|
signal activate_seg(int)
|
||||||
signal eat_apple
|
signal eat_apple
|
||||||
signal die #trigger game over logic
|
signal die #trigger game over logic
|
||||||
|
signal pickup_apple
|
||||||
|
signal burn_apple
|
||||||
|
|
||||||
var current_seg : Node2D
|
var current_seg : Node2D
|
||||||
var cur_id : int = 0
|
var cur_id : int = 0
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,15 @@ var food : float = 5
|
||||||
@export var max_food = 5
|
@export var max_food = 5
|
||||||
@export var food_drain = 0.1
|
@export var food_drain = 0.1
|
||||||
var pit_apples : int = 0
|
var pit_apples : int = 0
|
||||||
|
var burn_apples : float = 0
|
||||||
|
var score : int = 0
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Router.activate_seg.connect(activate_segment)
|
Router.activate_seg.connect(activate_segment)
|
||||||
Router.eat_apple.connect(rec_apple)
|
Router.eat_apple.connect(rec_apple)
|
||||||
|
Router.pickup_apple.connect(pickupApple)
|
||||||
|
Router.burn_apple.connect(burnApple)
|
||||||
food = max_food
|
food = max_food
|
||||||
#segements = get_children() as Array[snake_segment]
|
#segements = get_children() as Array[snake_segment]
|
||||||
segements.assign(segements_holder.get_children())
|
segements.assign(segements_holder.get_children())
|
||||||
|
|
@ -38,9 +42,18 @@ func _process(delta: float) -> void:
|
||||||
if(Input.is_action_just_pressed("test_add_segment")):
|
if(Input.is_action_just_pressed("test_add_segment")):
|
||||||
add_segment()
|
add_segment()
|
||||||
|
|
||||||
|
|
||||||
|
burn_apples -= 0.2 * delta
|
||||||
|
if burn_apples <= 0:
|
||||||
|
burn_apples = 0
|
||||||
|
else:
|
||||||
|
food += 0.3 * delta
|
||||||
|
|
||||||
if food > max_food:
|
if food > max_food:
|
||||||
food = max_food
|
food = max_food
|
||||||
food -= food_drain * delta
|
food -= food_drain * delta
|
||||||
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func activate_segment(act_segment : int):
|
func activate_segment(act_segment : int):
|
||||||
|
|
@ -73,8 +86,15 @@ func add_segment():
|
||||||
func rec_apple():
|
func rec_apple():
|
||||||
#food += 1
|
#food += 1
|
||||||
pit_apples += 1
|
pit_apples += 1
|
||||||
SNAKE_SPEED += 0.1
|
SNAKE_SPEED += 0.03
|
||||||
|
score += 5
|
||||||
add_segment()
|
add_segment()
|
||||||
for seg in segements:
|
for seg in segements:
|
||||||
seg.snake_speed = SNAKE_SPEED
|
seg.snake_speed = SNAKE_SPEED
|
||||||
|
|
||||||
|
func pickupApple():
|
||||||
|
pit_apples -= 1
|
||||||
|
|
||||||
|
func burnApple():
|
||||||
|
burn_apples += 1
|
||||||
|
score += 5
|
||||||
|
|
|
||||||
76
test.tscn
76
test.tscn
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=16 format=3 uid="uid://daqqurdrnk61h"]
|
[gd_scene load_steps=19 format=3 uid="uid://daqqurdrnk61h"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bue4xxejdsmqh" path="res://snakeManager.gd" id="1_6uqi0"]
|
[ext_resource type="Script" uid="uid://bue4xxejdsmqh" path="res://snakeManager.gd" id="1_6uqi0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bwoeu7ask0fck" path="res://prefabs/snake_segment.tscn" id="1_8uh7m"]
|
[ext_resource type="PackedScene" uid="uid://bwoeu7ask0fck" path="res://prefabs/snake_segment.tscn" id="1_8uh7m"]
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
[ext_resource type="Script" uid="uid://btw5oi52pxy7d" path="res://apple_pit_man.gd" id="6_77dp3"]
|
[ext_resource type="Script" uid="uid://btw5oi52pxy7d" path="res://apple_pit_man.gd" id="6_77dp3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://qpjwodeafyno" path="res://prefabs/apple.tscn" id="6_g14j6"]
|
[ext_resource type="PackedScene" uid="uid://qpjwodeafyno" path="res://prefabs/apple.tscn" id="6_g14j6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bl5py87o1qbgr" path="res://prefabs/wall.tscn" id="7_vbegm"]
|
[ext_resource type="PackedScene" uid="uid://bl5py87o1qbgr" path="res://prefabs/wall.tscn" id="7_vbegm"]
|
||||||
|
[ext_resource type="Script" uid="uid://dib0u5gw356nv" path="res://apple_furnace_man.gd" id="8_5tkv4"]
|
||||||
[ext_resource type="Script" uid="uid://cpav6iuq2hrns" path="res://uiman.gd" id="9_xersf"]
|
[ext_resource type="Script" uid="uid://cpav6iuq2hrns" path="res://uiman.gd" id="9_xersf"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dyxnlko6tpmui" path="res://icon.svg" id="11_77dp3"]
|
[ext_resource type="Texture2D" uid="uid://dyxnlko6tpmui" path="res://icon.svg" id="11_77dp3"]
|
||||||
|
|
||||||
|
|
@ -19,14 +20,23 @@ outline_size = 8
|
||||||
outline_color = Color(1, 0.478431, 1, 1)
|
outline_color = Color(1, 0.478431, 1, 1)
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_00tp4"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_00tp4"]
|
||||||
radius = 80.0
|
radius = 64.0
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_77dp3"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_77dp3"]
|
||||||
radius = 80.0
|
radius = 64.0
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_77dp3"]
|
||||||
|
font_size = 36
|
||||||
|
font_color = Color(1, 0.490271, 0.0740941, 1)
|
||||||
|
outline_size = 8
|
||||||
|
outline_color = Color(0.87451, 0, 0, 1)
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ehkex"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ehkex"]
|
||||||
radius = 50.0
|
radius = 50.0
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_5tkv4"]
|
||||||
|
font_size = 8
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D" node_paths=PackedStringArray("test_area")]
|
[node name="Node2D" type="Node2D" node_paths=PackedStringArray("test_area")]
|
||||||
script = ExtResource("1_ehkex")
|
script = ExtResource("1_ehkex")
|
||||||
top_left = Vector2(-1600, -1600)
|
top_left = Vector2(-1600, -1600)
|
||||||
|
|
@ -40,7 +50,7 @@ texture = ExtResource("1_vbegm")
|
||||||
[node name="Snake" type="Node2D" parent="." node_paths=PackedStringArray("segements_holder", "snake_line", "player")]
|
[node name="Snake" type="Node2D" parent="." node_paths=PackedStringArray("segements_holder", "snake_line", "player")]
|
||||||
script = ExtResource("1_6uqi0")
|
script = ExtResource("1_6uqi0")
|
||||||
segements_holder = NodePath("SegementHolder")
|
segements_holder = NodePath("SegementHolder")
|
||||||
SNAKE_SPEED = 0.6
|
SNAKE_SPEED = 0.4
|
||||||
snake_line = NodePath("Line2D")
|
snake_line = NodePath("Line2D")
|
||||||
player = NodePath("SegementHolder/SnakeSegment/Braincell")
|
player = NodePath("SegementHolder/SnakeSegment/Braincell")
|
||||||
|
|
||||||
|
|
@ -51,10 +61,12 @@ is_head = true
|
||||||
|
|
||||||
[node name="Braincell" parent="Snake/SegementHolder/SnakeSegment" instance=ExtResource("2_6uqi0")]
|
[node name="Braincell" parent="Snake/SegementHolder/SnakeSegment" instance=ExtResource("2_6uqi0")]
|
||||||
|
|
||||||
[node name="ApplePit" type="Node2D" parent="Snake/SegementHolder/SnakeSegment" node_paths=PackedStringArray("snake_man", "count")]
|
[node name="ApplePit" type="Node2D" parent="Snake/SegementHolder/SnakeSegment" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain")]
|
||||||
script = ExtResource("6_77dp3")
|
script = ExtResource("6_77dp3")
|
||||||
snake_man = NodePath("../../..")
|
snake_man = NodePath("../../..")
|
||||||
count = NodePath("Label")
|
count = NodePath("Label")
|
||||||
|
my_area = NodePath("Area2D")
|
||||||
|
brain = NodePath("../Braincell")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit"]
|
[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit"]
|
||||||
texture = ExtResource("11_77dp3")
|
texture = ExtResource("11_77dp3")
|
||||||
|
|
@ -77,8 +89,14 @@ debug_color = Color(0.988946, 0, 0.296194, 0.42)
|
||||||
[node name="SnakeSegment2" parent="Snake/SegementHolder" node_paths=PackedStringArray("next_segment") instance=ExtResource("1_8uh7m")]
|
[node name="SnakeSegment2" parent="Snake/SegementHolder" node_paths=PackedStringArray("next_segment") instance=ExtResource("1_8uh7m")]
|
||||||
position = Vector2(-320, 0)
|
position = Vector2(-320, 0)
|
||||||
next_segment = NodePath("../SnakeSegment")
|
next_segment = NodePath("../SnakeSegment")
|
||||||
|
door_disabled = true
|
||||||
|
|
||||||
[node name="AppleFurnace" type="Node2D" parent="Snake/SegementHolder/SnakeSegment2"]
|
[node name="AppleFurnace" type="Node2D" parent="Snake/SegementHolder/SnakeSegment2" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain")]
|
||||||
|
script = ExtResource("8_5tkv4")
|
||||||
|
snake_man = NodePath("../../..")
|
||||||
|
count = NodePath("Label2")
|
||||||
|
my_area = NodePath("Area2D")
|
||||||
|
brain = NodePath("../../SnakeSegment/Braincell")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"]
|
[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"]
|
||||||
texture = ExtResource("11_77dp3")
|
texture = ExtResource("11_77dp3")
|
||||||
|
|
@ -89,9 +107,19 @@ texture = ExtResource("11_77dp3")
|
||||||
shape = SubResource("CircleShape2D_77dp3")
|
shape = SubResource("CircleShape2D_77dp3")
|
||||||
debug_color = Color(0.878864, 0.340076, 3.85046e-07, 0.42)
|
debug_color = Color(0.878864, 0.340076, 3.85046e-07, 0.42)
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"]
|
||||||
|
offset_left = -80.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
text = "3"
|
||||||
|
label_settings = SubResource("LabelSettings_77dp3")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 2
|
||||||
|
|
||||||
[node name="SnakeSegment3" parent="Snake/SegementHolder" node_paths=PackedStringArray("next_segment") instance=ExtResource("1_8uh7m")]
|
[node name="SnakeSegment3" parent="Snake/SegementHolder" node_paths=PackedStringArray("next_segment") instance=ExtResource("1_8uh7m")]
|
||||||
position = Vector2(-640, 0)
|
position = Vector2(-640, 0)
|
||||||
next_segment = NodePath("../SnakeSegment2")
|
next_segment = NodePath("../SnakeSegment2")
|
||||||
|
door_disabled = true
|
||||||
|
|
||||||
[node name="Line2D" type="Line2D" parent="Snake"]
|
[node name="Line2D" type="Line2D" parent="Snake"]
|
||||||
width = 320.0
|
width = 320.0
|
||||||
|
|
@ -137,7 +165,7 @@ shape = SubResource("CircleShape2D_ehkex")
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="Control" type="Control" parent="CanvasLayer" node_paths=PackedStringArray("food_bar", "snake_manager")]
|
[node name="Control" type="Control" parent="CanvasLayer" node_paths=PackedStringArray("food_bar", "snake_manager", "score_label")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
@ -147,6 +175,7 @@ grow_vertical = 2
|
||||||
script = ExtResource("9_xersf")
|
script = ExtResource("9_xersf")
|
||||||
food_bar = NodePath("PanelContainer/HBoxContainer/ProgressBar")
|
food_bar = NodePath("PanelContainer/HBoxContainer/ProgressBar")
|
||||||
snake_manager = NodePath("../../Snake")
|
snake_manager = NodePath("../../Snake")
|
||||||
|
score_label = NodePath("PanelContainer2/VBoxContainer/score_label")
|
||||||
|
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer/Control"]
|
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer/Control"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
@ -168,3 +197,36 @@ text = "Food:"
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
step = 0.0
|
step = 0.0
|
||||||
|
|
||||||
|
[node name="PanelContainer2" type="PanelContainer" parent="CanvasLayer/Control"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control/PanelContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer/Control/PanelContainer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Score"
|
||||||
|
|
||||||
|
[node name="score_label" type="Label" parent="CanvasLayer/Control/PanelContainer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "0"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="PanelContainer3" type="PanelContainer" parent="CanvasLayer/Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -80.0
|
||||||
|
offset_bottom = 65.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer/Control/PanelContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Press enter to switch between inside and outside view"
|
||||||
|
label_settings = SubResource("LabelSettings_5tkv4")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
autowrap_mode = 2
|
||||||
|
|
|
||||||
212
test.tscn6344725845.tmp
Normal file
212
test.tscn6344725845.tmp
Normal file
|
|
@ -0,0 +1,212 @@
|
||||||
|
[gd_scene load_steps=18 format=3 uid="uid://daqqurdrnk61h"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bue4xxejdsmqh" path="res://snakeManager.gd" id="1_6uqi0"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bwoeu7ask0fck" path="res://prefabs/snake_segment.tscn" id="1_8uh7m"]
|
||||||
|
[ext_resource type="Script" uid="uid://cvsonvlgpi43g" path="res://fieldManager.gd" id="1_ehkex"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b1sese4p8sck3" path="res://assets/smallMap.png" id="1_vbegm"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cusdydgg4b1bo" path="res://prefabs/braincell.tscn" id="2_6uqi0"]
|
||||||
|
[ext_resource type="Script" uid="uid://b0djy8fmq4qjq" path="res://camera_2d.gd" id="5_ykrsh"]
|
||||||
|
[ext_resource type="Script" uid="uid://btw5oi52pxy7d" path="res://apple_pit_man.gd" id="6_77dp3"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://qpjwodeafyno" path="res://prefabs/apple.tscn" id="6_g14j6"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bl5py87o1qbgr" path="res://prefabs/wall.tscn" id="7_vbegm"]
|
||||||
|
[ext_resource type="Script" uid="uid://dib0u5gw356nv" path="res://apple_furnace_man.gd" id="8_5tkv4"]
|
||||||
|
[ext_resource type="Script" uid="uid://cpav6iuq2hrns" path="res://uiman.gd" id="9_xersf"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dyxnlko6tpmui" path="res://icon.svg" id="11_77dp3"]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_00tp4"]
|
||||||
|
font_size = 36
|
||||||
|
font_color = Color(1, 0, 0, 1)
|
||||||
|
outline_size = 8
|
||||||
|
outline_color = Color(1, 0.478431, 1, 1)
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_00tp4"]
|
||||||
|
radius = 64.0
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_77dp3"]
|
||||||
|
radius = 64.0
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_77dp3"]
|
||||||
|
font_size = 36
|
||||||
|
font_color = Color(1, 0.490271, 0.0740941, 1)
|
||||||
|
outline_size = 8
|
||||||
|
outline_color = Color(0.87451, 0, 0, 1)
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ehkex"]
|
||||||
|
radius = 50.0
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D" node_paths=PackedStringArray("test_area")]
|
||||||
|
script = ExtResource("1_ehkex")
|
||||||
|
top_left = Vector2(-1600, -1600)
|
||||||
|
test_area = NodePath("TestArea")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(-160, -160)
|
||||||
|
scale = Vector2(320, 320)
|
||||||
|
texture = ExtResource("1_vbegm")
|
||||||
|
|
||||||
|
[node name="Snake" type="Node2D" parent="." node_paths=PackedStringArray("segements_holder", "snake_line", "player")]
|
||||||
|
script = ExtResource("1_6uqi0")
|
||||||
|
segements_holder = NodePath("SegementHolder")
|
||||||
|
SNAKE_SPEED = 0.4
|
||||||
|
snake_line = NodePath("Line2D")
|
||||||
|
player = NodePath("SegementHolder/SnakeSegment/Braincell")
|
||||||
|
|
||||||
|
[node name="SegementHolder" type="Node2D" parent="Snake"]
|
||||||
|
|
||||||
|
[node name="SnakeSegment" parent="Snake/SegementHolder" instance=ExtResource("1_8uh7m")]
|
||||||
|
is_head = true
|
||||||
|
|
||||||
|
[node name="Braincell" parent="Snake/SegementHolder/SnakeSegment" instance=ExtResource("2_6uqi0")]
|
||||||
|
|
||||||
|
[node name="ApplePit" type="Node2D" parent="Snake/SegementHolder/SnakeSegment" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain")]
|
||||||
|
script = ExtResource("6_77dp3")
|
||||||
|
snake_man = NodePath("../../..")
|
||||||
|
count = NodePath("Label")
|
||||||
|
my_area = NodePath("Area2D")
|
||||||
|
brain = NodePath("../Braincell")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit"]
|
||||||
|
texture = ExtResource("11_77dp3")
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Snake/SegementHolder/SnakeSegment/ApplePit"]
|
||||||
|
offset_left = -80.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
text = "3"
|
||||||
|
label_settings = SubResource("LabelSettings_00tp4")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 2
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit"]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit/Area2D"]
|
||||||
|
shape = SubResource("CircleShape2D_00tp4")
|
||||||
|
debug_color = Color(0.988946, 0, 0.296194, 0.42)
|
||||||
|
|
||||||
|
[node name="SnakeSegment2" parent="Snake/SegementHolder" node_paths=PackedStringArray("next_segment") instance=ExtResource("1_8uh7m")]
|
||||||
|
position = Vector2(-320, 0)
|
||||||
|
next_segment = NodePath("../SnakeSegment")
|
||||||
|
door_disabled = true
|
||||||
|
|
||||||
|
[node name="AppleFurnace" type="Node2D" parent="Snake/SegementHolder/SnakeSegment2" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain")]
|
||||||
|
script = ExtResource("8_5tkv4")
|
||||||
|
snake_man = NodePath("../../..")
|
||||||
|
count = NodePath("Label2")
|
||||||
|
my_area = NodePath("Area2D")
|
||||||
|
brain = NodePath("../../SnakeSegment/Braincell")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"]
|
||||||
|
texture = ExtResource("11_77dp3")
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace/Area2D"]
|
||||||
|
shape = SubResource("CircleShape2D_77dp3")
|
||||||
|
debug_color = Color(0.878864, 0.340076, 3.85046e-07, 0.42)
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"]
|
||||||
|
offset_left = -80.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
text = "3"
|
||||||
|
label_settings = SubResource("LabelSettings_77dp3")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 2
|
||||||
|
|
||||||
|
[node name="SnakeSegment3" parent="Snake/SegementHolder" node_paths=PackedStringArray("next_segment") instance=ExtResource("1_8uh7m")]
|
||||||
|
position = Vector2(-640, 0)
|
||||||
|
next_segment = NodePath("../SnakeSegment2")
|
||||||
|
door_disabled = true
|
||||||
|
|
||||||
|
[node name="Line2D" type="Line2D" parent="Snake"]
|
||||||
|
width = 320.0
|
||||||
|
default_color = Color(0, 0.662728, 1.54018e-06, 1)
|
||||||
|
joint_mode = 2
|
||||||
|
begin_cap_mode = 2
|
||||||
|
end_cap_mode = 2
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="." node_paths=PackedStringArray("snake_line", "player")]
|
||||||
|
zoom = Vector2(0.1, 0.1)
|
||||||
|
script = ExtResource("5_ykrsh")
|
||||||
|
snake_line = NodePath("../Snake/Line2D")
|
||||||
|
player = NodePath("../Snake/SegementHolder/SnakeSegment/Braincell")
|
||||||
|
|
||||||
|
[node name="Apple" parent="." instance=ExtResource("6_g14j6")]
|
||||||
|
position = Vector2(0, -640)
|
||||||
|
|
||||||
|
[node name="Apple2" parent="." instance=ExtResource("6_g14j6")]
|
||||||
|
position = Vector2(640, 0)
|
||||||
|
|
||||||
|
[node name="Wall" parent="." instance=ExtResource("7_vbegm")]
|
||||||
|
position = Vector2(-160, -1920)
|
||||||
|
|
||||||
|
[node name="Wall2" parent="." instance=ExtResource("7_vbegm")]
|
||||||
|
position = Vector2(-160, 1600)
|
||||||
|
|
||||||
|
[node name="Wall3" parent="." instance=ExtResource("7_vbegm")]
|
||||||
|
position = Vector2(-1920, -160)
|
||||||
|
rotation = 1.5708
|
||||||
|
|
||||||
|
[node name="Wall4" parent="." instance=ExtResource("7_vbegm")]
|
||||||
|
position = Vector2(1600, -160)
|
||||||
|
rotation = 1.5708
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="."]
|
||||||
|
position = Vector2(-1600, -1600)
|
||||||
|
|
||||||
|
[node name="TestArea" type="Area2D" parent="."]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestArea"]
|
||||||
|
shape = SubResource("CircleShape2D_ehkex")
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="CanvasLayer" node_paths=PackedStringArray("food_bar", "snake_manager")]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("9_xersf")
|
||||||
|
food_bar = NodePath("PanelContainer/HBoxContainer/ProgressBar")
|
||||||
|
snake_manager = NodePath("../../Snake")
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="CanvasLayer/Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 12
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/Control/PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer/Control/PanelContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Food:"
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="CanvasLayer/Control/PanelContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
step = 0.0
|
||||||
|
|
||||||
|
[node name="PanelContainer2" type="PanelContainer" parent="CanvasLayer/Control"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control/PanelContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer/Control/PanelContainer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Score"
|
||||||
|
|
||||||
|
[node name="score_label" type="Label" parent="CanvasLayer/Control/PanelContainer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "0"
|
||||||
|
horizontal_alignment = 1
|
||||||
2
uiman.gd
2
uiman.gd
|
|
@ -2,6 +2,7 @@ extends Control
|
||||||
|
|
||||||
@export var food_bar : ProgressBar
|
@export var food_bar : ProgressBar
|
||||||
@export var snake_manager : Node2D
|
@export var snake_manager : Node2D
|
||||||
|
@export var score_label : Label
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
|
@ -13,3 +14,4 @@ func _ready() -> void:
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
food_bar.max_value = snake_manager.max_food
|
food_bar.max_value = snake_manager.max_food
|
||||||
food_bar.value = snake_manager.food
|
food_bar.value = snake_manager.food
|
||||||
|
score_label.text = str(snake_manager.score)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue