Added pickups and doors

This commit is contained in:
2026-01-07 17:33:42 +03:00
parent 33bbac64a1
commit 33cbfeebb9
40 changed files with 732 additions and 5 deletions
+6
View File
@@ -0,0 +1,6 @@
class_name BookDoor
extends ClosedDoor
func _is_key(node: Node) -> bool:
return node is BookPickup
+1
View File
@@ -0,0 +1 @@
uid://befuova1g4tth
+65
View File
@@ -0,0 +1,65 @@
[gd_scene load_steps=10 format=3 uid="uid://dioc4r03dfleq"]
[ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/closed_door.tscn" id="1_p87ci"]
[ext_resource type="Script" uid="uid://befuova1g4tth" path="res://game/doors/book_door.gd" id="2_atb6l"]
[ext_resource type="Texture2D" uid="uid://sfjjweantpja" path="res://images/level/doors.png" id="3_gbgmk"]
[sub_resource type="AtlasTexture" id="AtlasTexture_e14gj"]
atlas = ExtResource("3_gbgmk")
region = Rect2(0, 240, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_g21nq"]
atlas = ExtResource("3_gbgmk")
region = Rect2(64, 240, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_op86a"]
atlas = ExtResource("3_gbgmk")
region = Rect2(0, 240, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_fw6sy"]
atlas = ExtResource("3_gbgmk")
region = Rect2(32, 240, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_m0nqq"]
atlas = ExtResource("3_gbgmk")
region = Rect2(64, 240, 32, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_3d7ts"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_e14gj")
}],
"loop": true,
"name": &"closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_g21nq")
}],
"loop": true,
"name": &"open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_op86a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fw6sy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m0nqq")
}],
"loop": false,
"name": &"opening",
"speed": 10.0
}]
[node name="BookDoor" instance=ExtResource("1_p87ci")]
script = ExtResource("2_atb6l")
[node name="AnimatedSprite2D" parent="." index="2"]
sprite_frames = SubResource("SpriteFrames_3d7ts")
animation = &"opening"
+6
View File
@@ -0,0 +1,6 @@
class_name CircleDoor
extends ClosedDoor
func _is_key(node: Node) -> bool:
return node is CircleKeyPickup
+1
View File
@@ -0,0 +1 @@
uid://50eqrh24tgx7
+64
View File
@@ -0,0 +1,64 @@
[gd_scene load_steps=10 format=3 uid="uid://g0n5npbt3hb2"]
[ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/closed_door.tscn" id="1_amonf"]
[ext_resource type="Texture2D" uid="uid://sfjjweantpja" path="res://images/level/doors.png" id="2_5d3q0"]
[ext_resource type="Script" uid="uid://50eqrh24tgx7" path="res://game/doors/circle_door.gd" id="2_t4nfh"]
[sub_resource type="AtlasTexture" id="AtlasTexture_t4nfh"]
atlas = ExtResource("2_5d3q0")
region = Rect2(0, 96, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_bcn3i"]
atlas = ExtResource("2_5d3q0")
region = Rect2(64, 96, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_wv48j"]
atlas = ExtResource("2_5d3q0")
region = Rect2(0, 96, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_3ybwy"]
atlas = ExtResource("2_5d3q0")
region = Rect2(32, 96, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_7go8b"]
atlas = ExtResource("2_5d3q0")
region = Rect2(64, 96, 32, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_18a0u"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_t4nfh")
}],
"loop": true,
"name": &"closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_bcn3i")
}],
"loop": true,
"name": &"open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_wv48j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3ybwy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_7go8b")
}],
"loop": false,
"name": &"opening",
"speed": 10.0
}]
[node name="CircleDoor" instance=ExtResource("1_amonf")]
script = ExtResource("2_t4nfh")
[node name="AnimatedSprite2D" parent="." index="2"]
sprite_frames = SubResource("SpriteFrames_18a0u")
+18
View File
@@ -0,0 +1,18 @@
class_name ClosedDoor
extends Door
func _is_key(_node: Node) -> bool:
return false
func _can_open(body: Node2D) -> bool:
if not body.has_node("Pickups"): return false
if not body.has_method("remove_pickup"): return false
for pickup in body.get_node("Pickups").get_children():
if _is_key(pickup):
body.remove_pickup(pickup)
return true
return false
+1
View File
@@ -0,0 +1 @@
uid://qd7aihqwgddj
+65
View File
@@ -0,0 +1,65 @@
[gd_scene load_steps=10 format=3 uid="uid://cojxqx5al7kyv"]
[ext_resource type="PackedScene" uid="uid://b7mhdrj3b6loq" path="res://game/doors/door.tscn" id="1_rxn60"]
[ext_resource type="Script" uid="uid://qd7aihqwgddj" path="res://game/doors/closed_door.gd" id="2_dntl7"]
[ext_resource type="Texture2D" uid="uid://sfjjweantpja" path="res://images/level/doors.png" id="3_dntl7"]
[sub_resource type="AtlasTexture" id="AtlasTexture_3gkgk"]
atlas = ExtResource("3_dntl7")
region = Rect2(0, 48, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_gu75k"]
atlas = ExtResource("3_dntl7")
region = Rect2(64, 48, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_l618y"]
atlas = ExtResource("3_dntl7")
region = Rect2(0, 48, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_s3oqg"]
atlas = ExtResource("3_dntl7")
region = Rect2(32, 48, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ir1gv"]
atlas = ExtResource("3_dntl7")
region = Rect2(64, 48, 32, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_fgn1o"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_3gkgk")
}],
"loop": true,
"name": &"closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_gu75k")
}],
"loop": true,
"name": &"open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_l618y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_s3oqg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ir1gv")
}],
"loop": false,
"name": &"opening",
"speed": 10.0
}]
[node name="ClosedDoor" instance=ExtResource("1_rxn60")]
script = ExtResource("2_dntl7")
[node name="AnimatedSprite2D" parent="." index="2"]
sprite_frames = SubResource("SpriteFrames_fgn1o")
animation = &"closed"
+39
View File
@@ -0,0 +1,39 @@
class_name Door
extends Node2D
const ANIMATION_CLOSED = "closed"
const ANIMATION_OPEN = "open"
const ANIMATION_OPENING = "opening"
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
@onready var static_body : StaticBody2D = $StaticBody2D
@onready var static_body_collision : CollisionShape2D = $%StaticBodyCollision
@onready var area_collision : CollisionShape2D = $%AreaCollision
func _ready() -> void:
sprite.play(ANIMATION_CLOSED)
func _is_closed() -> bool:
return sprite.animation == ANIMATION_CLOSED
func _can_open(_body: Node2D) -> bool:
return true
func _open() -> void:
sprite.play(ANIMATION_OPENING)
static_body.process_mode = Node.PROCESS_MODE_DISABLED
func _on_animation_finished() -> void:
sprite.play(ANIMATION_OPEN)
func _on_area_entered(body: Node2D) -> void:
if _is_closed() and _can_open(body):
_open()
+1
View File
@@ -0,0 +1 @@
uid://5uqub2a6701b
+91
View File
@@ -0,0 +1,91 @@
[gd_scene load_steps=12 format=3 uid="uid://b7mhdrj3b6loq"]
[ext_resource type="Script" uid="uid://5uqub2a6701b" path="res://game/doors/door.gd" id="1_vx1od"]
[ext_resource type="Material" uid="uid://dojhoc6ljpt1a" path="res://game/materials/gray_walls.tres" id="1_xelsh"]
[ext_resource type="Texture2D" uid="uid://sfjjweantpja" path="res://images/level/doors.png" id="3_ymlcn"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_cs8ri"]
size = Vector2(9, 48)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_u7b5a"]
size = Vector2(48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_5nqrw"]
atlas = ExtResource("3_ymlcn")
region = Rect2(0, 0, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ymlcn"]
atlas = ExtResource("3_ymlcn")
region = Rect2(64, 0, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_r8rhb"]
atlas = ExtResource("3_ymlcn")
region = Rect2(0, 0, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_xb6pu"]
atlas = ExtResource("3_ymlcn")
region = Rect2(32, 0, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_j83fq"]
atlas = ExtResource("3_ymlcn")
region = Rect2(64, 0, 32, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_r8rhb"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_5nqrw")
}],
"loop": true,
"name": &"closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ymlcn")
}],
"loop": true,
"name": &"open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_r8rhb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xb6pu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j83fq")
}],
"loop": false,
"name": &"opening",
"speed": 10.0
}]
[node name="Door" type="Node2D"]
script = ExtResource("1_vx1od")
[node name="StaticBody2D" type="StaticBody2D" parent="."]
position = Vector2(-8.5, 0)
[node name="StaticBodyCollision" type="CollisionShape2D" parent="StaticBody2D"]
unique_name_in_owner = true
shape = SubResource("RectangleShape2D_cs8ri")
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(-8.5, 0)
collision_layer = 0
collision_mask = 136
[node name="AreaCollision" type="CollisionShape2D" parent="Area2D"]
unique_name_in_owner = true
shape = SubResource("RectangleShape2D_u7b5a")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
material = ExtResource("1_xelsh")
sprite_frames = SubResource("SpriteFrames_r8rhb")
animation = &"opening"
[connection signal="body_entered" from="Area2D" to="." method="_on_area_entered"]
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]
+6
View File
@@ -0,0 +1,6 @@
class_name SquareDoor
extends ClosedDoor
func _is_key(node: Node) -> bool:
return node is SquareKeyPickup
+1
View File
@@ -0,0 +1 @@
uid://mp2dfsd1uk5p
+64
View File
@@ -0,0 +1,64 @@
[gd_scene load_steps=10 format=3 uid="uid://b7imlh4sl036i"]
[ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/closed_door.tscn" id="1_jg0qv"]
[ext_resource type="Script" uid="uid://mp2dfsd1uk5p" path="res://game/doors/square_door.gd" id="2_wyn1t"]
[ext_resource type="Texture2D" uid="uid://sfjjweantpja" path="res://images/level/doors.png" id="3_txk00"]
[sub_resource type="AtlasTexture" id="AtlasTexture_qhb0j"]
atlas = ExtResource("3_txk00")
region = Rect2(0, 144, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_rwkr8"]
atlas = ExtResource("3_txk00")
region = Rect2(64, 144, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_pw0e3"]
atlas = ExtResource("3_txk00")
region = Rect2(0, 144, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_tlxsa"]
atlas = ExtResource("3_txk00")
region = Rect2(32, 144, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_05hqc"]
atlas = ExtResource("3_txk00")
region = Rect2(64, 144, 32, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_wk632"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qhb0j")
}],
"loop": true,
"name": &"closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rwkr8")
}],
"loop": true,
"name": &"open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_pw0e3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tlxsa")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_05hqc")
}],
"loop": false,
"name": &"opening",
"speed": 10.0
}]
[node name="SquareDoor" instance=ExtResource("1_jg0qv")]
script = ExtResource("2_wyn1t")
[node name="AnimatedSprite2D" parent="." index="2"]
sprite_frames = SubResource("SpriteFrames_wk632")
+6
View File
@@ -0,0 +1,6 @@
class_name TriagleDoor
extends ClosedDoor
func _is_key(node: Node) -> bool:
return node is TriangleKeyPickup
+1
View File
@@ -0,0 +1 @@
uid://d4lrt6yw0knf7
+64
View File
@@ -0,0 +1,64 @@
[gd_scene load_steps=10 format=3 uid="uid://dwvv5dj8lqif2"]
[ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/closed_door.tscn" id="1_l21ff"]
[ext_resource type="Script" uid="uid://d4lrt6yw0knf7" path="res://game/doors/triangle_door.gd" id="2_ifpbb"]
[ext_resource type="Texture2D" uid="uid://sfjjweantpja" path="res://images/level/doors.png" id="3_eqipl"]
[sub_resource type="AtlasTexture" id="AtlasTexture_rb7ia"]
atlas = ExtResource("3_eqipl")
region = Rect2(0, 192, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_1a8ca"]
atlas = ExtResource("3_eqipl")
region = Rect2(64, 192, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_nkv11"]
atlas = ExtResource("3_eqipl")
region = Rect2(0, 192, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qx6bn"]
atlas = ExtResource("3_eqipl")
region = Rect2(32, 192, 32, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_vlkqk"]
atlas = ExtResource("3_eqipl")
region = Rect2(64, 192, 32, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_o203p"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rb7ia")
}],
"loop": true,
"name": &"closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_1a8ca")
}],
"loop": true,
"name": &"open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_nkv11")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qx6bn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vlkqk")
}],
"loop": false,
"name": &"opening",
"speed": 10.0
}]
[node name="TriangleDoor" instance=ExtResource("1_l21ff")]
script = ExtResource("2_ifpbb")
[node name="AnimatedSprite2D" parent="." index="2"]
sprite_frames = SubResource("SpriteFrames_o203p")