Box and button logic + some more sfx
|
@ -1,16 +1,21 @@
|
||||||
|
class_name Player
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
@export var speed: float = 40
|
|
||||||
|
|
||||||
@onready var raycast: RayCast2D = $RayCast2D
|
@onready var raycast: RayCast2D = $RayCast2D
|
||||||
|
@onready var tile_map: TileMapLayer = $"../TileMapLayer"
|
||||||
|
|
||||||
|
@export var speed: float = 40
|
||||||
|
@export var respawn_point: Marker2D
|
||||||
|
|
||||||
const TILE_SIZE = 8
|
const TILE_SIZE = 8
|
||||||
|
|
||||||
var is_moving = false
|
var is_moving = false
|
||||||
|
var should_move = false
|
||||||
var input_dir: Vector2
|
var input_dir: Vector2
|
||||||
var prev_input: Vector2
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
print(tile_map)
|
||||||
|
_respawn()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
@ -20,41 +25,55 @@ func _process(delta):
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
_try_move()
|
_try_move()
|
||||||
|
|
||||||
|
func _respawn():
|
||||||
|
position = respawn_point.position
|
||||||
|
|
||||||
func _try_move():
|
func _try_move():
|
||||||
input_dir = Vector2.ZERO
|
should_move = false
|
||||||
if Input.is_action_pressed("move_up"):
|
if Input.is_action_pressed("move_up"):
|
||||||
input_dir = Vector2.UP
|
input_dir = Vector2.UP
|
||||||
|
should_move = true
|
||||||
elif Input.is_action_pressed("move_right"):
|
elif Input.is_action_pressed("move_right"):
|
||||||
input_dir = Vector2.RIGHT
|
input_dir = Vector2.RIGHT
|
||||||
|
should_move = true
|
||||||
elif Input.is_action_pressed("move_down"):
|
elif Input.is_action_pressed("move_down"):
|
||||||
input_dir = Vector2.DOWN
|
input_dir = Vector2.DOWN
|
||||||
|
should_move = true
|
||||||
elif Input.is_action_pressed("move_left"):
|
elif Input.is_action_pressed("move_left"):
|
||||||
input_dir = Vector2.LEFT
|
input_dir = Vector2.LEFT
|
||||||
|
should_move = true
|
||||||
|
|
||||||
if input_dir and !is_moving:
|
if should_move and !is_moving:
|
||||||
raycast.target_position = input_dir * 8
|
raycast.target_position = input_dir * 8
|
||||||
|
raycast.force_raycast_update()
|
||||||
|
|
||||||
if input_dir != prev_input:
|
|
||||||
prev_input = input_dir
|
|
||||||
return
|
|
||||||
|
|
||||||
var collision = raycast.get_collider()
|
|
||||||
if raycast.is_colliding():
|
if raycast.is_colliding():
|
||||||
return
|
return
|
||||||
|
|
||||||
is_moving = true
|
is_moving = true
|
||||||
prev_input = input_dir
|
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(self, "position", position + input_dir * TILE_SIZE, 0.25)
|
tween.tween_property(self, "position", position + input_dir * TILE_SIZE, 0.25)
|
||||||
tween.tween_callback(func():
|
tween.tween_callback(func():
|
||||||
is_moving = false
|
is_moving = false
|
||||||
|
_post_movement_check()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func _post_movement_check():
|
||||||
|
var current_tile: Vector2i = tile_map.local_to_map(tile_map.to_local(global_position))
|
||||||
|
var tile_data: TileData = tile_map.get_cell_tile_data(current_tile)
|
||||||
|
if tile_data and tile_data.get_custom_data("death"):
|
||||||
|
die()
|
||||||
|
|
||||||
|
func die():
|
||||||
|
_respawn()
|
||||||
|
|
||||||
func _try_interact():
|
func _try_interact():
|
||||||
if Input.is_action_just_pressed("attack") and raycast.is_colliding():
|
raycast.target_position = input_dir * 8
|
||||||
var collision = raycast.get_collider()
|
raycast.force_raycast_update()
|
||||||
if collision is PuzzleElement:
|
|
||||||
(collision as PuzzleElement).interact()
|
var collider = raycast.get_collider()
|
||||||
|
if Input.is_action_just_pressed("attack") and collider:
|
||||||
|
if collider is PuzzleElement:
|
||||||
|
(collider as PuzzleElement).interact(self)
|
||||||
pass
|
pass
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -45,7 +45,7 @@ _data = {
|
||||||
size = Vector2(8, 8)
|
size = Vector2(8, 8)
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D"]
|
[node name="Player" type="CharacterBody2D"]
|
||||||
z_index = 1
|
z_index = 10
|
||||||
collision_mask = 3
|
collision_mask = 3
|
||||||
script = ExtResource("1_jrd75")
|
script = ExtResource("1_jrd75")
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,6 @@ jump={
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
textures/canvas_textures/default_texture_filter=0
|
||||||
renderer/rendering_method="gl_compatibility"
|
renderer/rendering_method="gl_compatibility"
|
||||||
renderer/rendering_method.mobile="gl_compatibility"
|
renderer/rendering_method.mobile="gl_compatibility"
|
||||||
|
|
After Width: | Height: | Size: 211 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ccs76qyn4ua40"
|
||||||
|
path="res://.godot/imported/ball.png-af3ade1b257b8ed9271b5f017682059c.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://puzzles/assets/ball.png"
|
||||||
|
dest_files=["res://.godot/imported/ball.png-af3ade1b257b8ed9271b5f017682059c.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 166 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b4i416bsd62n1"
|
||||||
|
path="res://.godot/imported/box-reset.png-42deb82a866e04ae79af81e52ec33c24.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://puzzles/assets/box-reset.png"
|
||||||
|
dest_files=["res://.godot/imported/box-reset.png-42deb82a866e04ae79af81e52ec33c24.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 120 B |
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://b4i416bsd62n1"
|
uid="uid://dmooh76emdwbh"
|
||||||
path="res://.godot/imported/box-switch.png-df9369c771924cc3ffd7d773f48b5997.ctex"
|
path="res://.godot/imported/box-switch.png-df9369c771924cc3ffd7d773f48b5997.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
|
|
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 189 B |
After Width: | Height: | Size: 186 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://d02y0dsfaynbl"
|
||||||
|
path="res://.godot/imported/button.png-4ab2aba3ab074d79fc4253edede3e408.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://puzzles/assets/button.png"
|
||||||
|
dest_files=["res://.godot/imported/button.png-4ab2aba3ab074d79fc4253edede3e408.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dtya31nfxo0h7"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ccs76qyn4ua40" path="res://puzzles/assets/ball.png" id="1_3p6vy"]
|
||||||
|
|
||||||
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_8in3v"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_we7nh"]
|
||||||
|
size = Vector2(14, 14)
|
||||||
|
|
||||||
|
[node name="Ball" type="StaticBody2D"]
|
||||||
|
collision_layer = 2
|
||||||
|
physics_material_override = SubResource("PhysicsMaterial_8in3v")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("1_3p6vy")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("RectangleShape2D_we7nh")
|
|
@ -0,0 +1,55 @@
|
||||||
|
class_name Box
|
||||||
|
extends PuzzleElement
|
||||||
|
|
||||||
|
@onready var raycast: RayCast2D = $RayCast2D
|
||||||
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||||
|
@onready var audio_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
|
||||||
|
@onready var manager: BoxPuzzle = $"../"
|
||||||
|
|
||||||
|
const TILE_SIZE = 8
|
||||||
|
|
||||||
|
var is_finished = false
|
||||||
|
var is_moving = false
|
||||||
|
var input_dir: Vector2
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func interact(player: Player):
|
||||||
|
if !is_finished and !is_moving:
|
||||||
|
input_dir = player.input_dir
|
||||||
|
raycast.target_position = player.input_dir * 8
|
||||||
|
raycast.force_raycast_update()
|
||||||
|
|
||||||
|
var collider = raycast.get_collider()
|
||||||
|
var is_switch = collider is BoxSwitch
|
||||||
|
if raycast.is_colliding() and not is_switch:
|
||||||
|
return
|
||||||
|
|
||||||
|
is_moving = true
|
||||||
|
audio_player.play()
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "position", position + input_dir * TILE_SIZE, 0.45)
|
||||||
|
tween.tween_callback(func():
|
||||||
|
is_moving = false
|
||||||
|
if is_switch:
|
||||||
|
complete()
|
||||||
|
)
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _check_completion():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func complete():
|
||||||
|
if is_finished:
|
||||||
|
return
|
||||||
|
|
||||||
|
animation_player.play(&"complete")
|
||||||
|
is_finished = true
|
|
@ -1,6 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://cjus07bbbn4wd"]
|
[gd_scene load_steps=8 format=3 uid="uid://cjus07bbbn4wd"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://puzzles/box/box.gd" id="1_d6g12"]
|
||||||
[ext_resource type="Texture2D" uid="uid://br4mm65ok0dfl" path="res://puzzles/assets/box.png" id="1_myqej"]
|
[ext_resource type="Texture2D" uid="uid://br4mm65ok0dfl" path="res://puzzles/assets/box.png" id="1_myqej"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://bnpey4rox545e" path="res://scenes/assets/jingles/hit.wav" id="3_3ug4u"]
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_21bg4"]
|
[sub_resource type="Animation" id="Animation_21bg4"]
|
||||||
resource_name = "RESET"
|
resource_name = "RESET"
|
||||||
|
@ -27,7 +29,7 @@ tracks/0/path = NodePath(".:frame")
|
||||||
tracks/0/interp = 1
|
tracks/0/interp = 1
|
||||||
tracks/0/loop_wrap = true
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
"times": PackedFloat32Array(0, 0.15, 0.3, 0.45),
|
"times": PackedFloat32Array(0.05, 0.2, 0.35, 0.5),
|
||||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
"update": 1,
|
"update": 1,
|
||||||
"values": [0, 1, 2, 3]
|
"values": [0, 1, 2, 3]
|
||||||
|
@ -39,7 +41,13 @@ _data = {
|
||||||
"complete": SubResource("Animation_db20y")
|
"complete": SubResource("Animation_db20y")
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Box" type="Node2D"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ptq6k"]
|
||||||
|
size = Vector2(8, 8)
|
||||||
|
|
||||||
|
[node name="Box" type="StaticBody2D"]
|
||||||
|
z_index = 10
|
||||||
|
collision_layer = 2
|
||||||
|
script = ExtResource("1_d6g12")
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
root_node = NodePath("../Sprite2D")
|
root_node = NodePath("../Sprite2D")
|
||||||
|
@ -52,3 +60,14 @@ autoplay = "RESET"
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
texture = ExtResource("1_myqej")
|
texture = ExtResource("1_myqej")
|
||||||
hframes = 5
|
hframes = 5
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("RectangleShape2D_ptq6k")
|
||||||
|
|
||||||
|
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||||
|
target_position = Vector2(0, 8)
|
||||||
|
collision_mask = 3
|
||||||
|
collide_with_areas = true
|
||||||
|
|
||||||
|
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||||
|
stream = ExtResource("3_3ug4u")
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
class_name BoxReset
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
@onready var reset_timer: Timer = $ResetTimer
|
||||||
|
|
||||||
|
@export var box: Box
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
reset_box(false)
|
||||||
|
|
||||||
|
func reset_box(has_offset: bool):
|
||||||
|
if !box.is_finished:
|
||||||
|
box.animation_player.play_backwards(&"complete")
|
||||||
|
box.position = position + (Vector2(8, 0) if has_offset else Vector2.ZERO)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body):
|
||||||
|
if body is Player:
|
||||||
|
var diff = box.position.distance_to(position)
|
||||||
|
if diff > 12:
|
||||||
|
reset_timer.start()
|
||||||
|
|
||||||
|
func _on_reset_timer_timeout():
|
||||||
|
reset_box(true)
|
|
@ -0,0 +1,70 @@
|
||||||
|
[gd_scene load_steps=7 format=3 uid="uid://dyllmgs8q1voh"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b4i416bsd62n1" path="res://puzzles/assets/box-reset.png" id="1_eosti"]
|
||||||
|
[ext_resource type="Script" path="res://puzzles/box/box_reset.gd" id="1_nqwqa"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g4f6l"]
|
||||||
|
size = Vector2(6, 6)
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_615sy"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_33k1i"]
|
||||||
|
resource_name = "active"
|
||||||
|
length = 0.5
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.25),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_78s6f"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_615sy"),
|
||||||
|
"active": SubResource("Animation_33k1i")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="BoxReset" type="Area2D"]
|
||||||
|
collision_layer = 4
|
||||||
|
script = ExtResource("1_nqwqa")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture_filter = 1
|
||||||
|
texture = ExtResource("1_eosti")
|
||||||
|
hframes = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("RectangleShape2D_g4f6l")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_78s6f")
|
||||||
|
}
|
||||||
|
autoplay = "active"
|
||||||
|
|
||||||
|
[node name="ResetTimer" type="Timer" parent="."]
|
||||||
|
wait_time = 0.25
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="timeout" from="ResetTimer" to="." method="_on_reset_timer_timeout"]
|
|
@ -0,0 +1,4 @@
|
||||||
|
class_name BoxSwitch
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
@export var start_point: BoxReset
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://c2qq84wh76mkx"]
|
[gd_scene load_steps=7 format=3 uid="uid://c2qq84wh76mkx"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://b4i416bsd62n1" path="res://puzzles/assets/box-switch.png" id="1_s5gx1"]
|
[ext_resource type="Script" path="res://puzzles/box/box_switch.gd" id="1_ixy7a"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dmooh76emdwbh" path="res://puzzles/assets/box-switch.png" id="1_s5gx1"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g4f6l"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g4f6l"]
|
||||||
size = Vector2(8, 8)
|
size = Vector2(8, 8)
|
||||||
|
@ -44,11 +45,11 @@ _data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="BoxSwitch" type="Area2D"]
|
[node name="BoxSwitch" type="Area2D"]
|
||||||
|
script = ExtResource("1_ixy7a")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
texture = ExtResource("1_s5gx1")
|
texture = ExtResource("1_s5gx1")
|
||||||
hframes = 2
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("RectangleShape2D_g4f6l")
|
shape = SubResource("RectangleShape2D_g4f6l")
|
||||||
|
@ -58,3 +59,5 @@ libraries = {
|
||||||
"": SubResource("AnimationLibrary_78s6f")
|
"": SubResource("AnimationLibrary_78s6f")
|
||||||
}
|
}
|
||||||
autoplay = "active"
|
autoplay = "active"
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
class_name BoxPuzzle
|
||||||
|
|
||||||
|
extends Puzzle
|
||||||
|
|
||||||
|
@export var boxes: Array[Box] = []
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var is_finished = true
|
||||||
|
for box in boxes:
|
||||||
|
if !box.is_finished:
|
||||||
|
is_finished = false
|
||||||
|
break;
|
||||||
|
|
||||||
|
if is_finished:
|
||||||
|
complete()
|
|
@ -0,0 +1,13 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
@onready var sprite = $Sprite2D
|
||||||
|
|
||||||
|
@export var nodes: Array[Node2D]
|
||||||
|
|
||||||
|
func _on_body_entered(body):
|
||||||
|
if body is Player:
|
||||||
|
for node in nodes:
|
||||||
|
if node is TileMapLayer:
|
||||||
|
var layer = node as TileMapLayer
|
||||||
|
layer.enabled = !layer.enabled
|
||||||
|
sprite.frame = 1 if not layer.enabled else 0
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://bdlyuun4o4val"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d02y0dsfaynbl" path="res://puzzles/assets/button.png" id="1_atyp4"]
|
||||||
|
[ext_resource type="Script" path="res://puzzles/button/button.gd" id="1_gpasp"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xj0k4"]
|
||||||
|
size = Vector2(6, 6)
|
||||||
|
|
||||||
|
[node name="Button" type="Area2D"]
|
||||||
|
script = ExtResource("1_gpasp")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("1_atyp4")
|
||||||
|
hframes = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("RectangleShape2D_xj0k4")
|
|
@ -9,27 +9,19 @@ extends PuzzleElement
|
||||||
@onready var audio_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
|
@onready var audio_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
|
||||||
@onready var manager: GravePuzzle = $"../"
|
@onready var manager: GravePuzzle = $"../"
|
||||||
|
|
||||||
@export var test = false
|
|
||||||
var is_singing = false
|
var is_singing = false
|
||||||
var is_finished = false
|
var is_finished = false
|
||||||
@export var last_used_tick = 60
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if last_used_tick > 0:
|
|
||||||
last_used_tick -= 1
|
|
||||||
|
|
||||||
if test and last_used_tick <= 0:
|
|
||||||
complete()
|
|
||||||
pair.complete()
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func interact():
|
func interact(player: Player):
|
||||||
manager.activate_grave(self)
|
manager.activate_grave(self)
|
||||||
|
|
||||||
func sing():
|
func sing():
|
||||||
|
|
|
@ -2,6 +2,8 @@ class_name GravePuzzle
|
||||||
|
|
||||||
extends Puzzle
|
extends Puzzle
|
||||||
|
|
||||||
|
@onready var timer: Timer = $Timer
|
||||||
|
|
||||||
@export var graves: Array[Grave] = []
|
@export var graves: Array[Grave] = []
|
||||||
|
|
||||||
var _last_grave: Grave
|
var _last_grave: Grave
|
||||||
|
@ -13,8 +15,12 @@ func _process(delta):
|
||||||
is_finished = false
|
is_finished = false
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if is_finished:
|
if !is_complete and is_finished:
|
||||||
complete()
|
# In case we forget or don't need to add a timer for some rooms
|
||||||
|
if timer and timer.is_stopped():
|
||||||
|
timer.start()
|
||||||
|
elif !timer:
|
||||||
|
complete()
|
||||||
|
|
||||||
func activate_grave(grave: Grave):
|
func activate_grave(grave: Grave):
|
||||||
if _last_grave == grave.pair:
|
if _last_grave == grave.pair:
|
||||||
|
@ -24,3 +30,7 @@ func activate_grave(grave: Grave):
|
||||||
|
|
||||||
grave.sing()
|
grave.sing()
|
||||||
_last_grave = grave
|
_last_grave = grave
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
complete()
|
||||||
|
|
|
@ -11,4 +11,5 @@ func complete():
|
||||||
return
|
return
|
||||||
|
|
||||||
is_complete = true
|
is_complete = true
|
||||||
|
|
||||||
complete_puzzle.emit()
|
complete_puzzle.emit()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class_name PuzzleElement
|
class_name PuzzleElement
|
||||||
extends Node
|
extends Node2D
|
||||||
|
|
||||||
func interact():
|
func interact(player: Player):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -5,10 +5,10 @@ extends PuzzleManager
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if is_room_finished():
|
if is_room_finished():
|
||||||
if next_room_fog != null:
|
pass
|
||||||
next_room_fog.queue_free()
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _on_demo_grave_puzzle_complete():
|
func _on_demo_grave_puzzle_complete():
|
||||||
print("Demo Puzzle 1 Solved")
|
if next_room_fog != null:
|
||||||
|
next_room_fog.queue_free()
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
3,0,0,0,120,16,4,1,204,0,1,128,0,256,1,0,0,0,0,4,36,1,3,0,39,1,2,0,40,1,1,0,41,1,0,0,0,1,0,1,0,-1,-1,-1,-1,-1,-1,-1,
|
|
@ -0,0 +1,24 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://dfc8jx220imb7"
|
||||||
|
path="res://.godot/imported/fail.wav-c48208a4611d55d0dcd0f0dbeab5bae3.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scenes/assets/jingles/fail.wav"
|
||||||
|
dest_files=["res://.godot/imported/fail.wav-c48208a4611d55d0dcd0f0dbeab5bae3.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=0
|
|
@ -0,0 +1 @@
|
||||||
|
3,0,0,0,120,2,2,1,365,1,20,128,0,256,1,11,0,0,0,2,17,1,0,0,19,1,1,0,0,1,0,1,0,-1,-1,-1,-1,-1,-1,-1,
|
|
@ -0,0 +1,24 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://bnpey4rox545e"
|
||||||
|
path="res://.godot/imported/hit.wav-9ed93b6b0157efac7b84138114833599.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scenes/assets/jingles/hit.wav"
|
||||||
|
dest_files=["res://.godot/imported/hit.wav-9ed93b6b0157efac7b84138114833599.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=0
|
|
@ -6,13 +6,17 @@
|
||||||
texture = ExtResource("1_al8fb")
|
texture = ExtResource("1_al8fb")
|
||||||
texture_region_size = Vector2i(8, 8)
|
texture_region_size = Vector2i(8, 8)
|
||||||
0:0/0 = 0
|
0:0/0 = 0
|
||||||
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
|
0:0/0/custom_data_1 = true
|
||||||
1:0/0 = 0
|
1:0/0 = 0
|
||||||
|
1:0/0/custom_data_0 = true
|
||||||
4:0/0 = 0
|
4:0/0 = 0
|
||||||
|
4:0/0/custom_data_0 = true
|
||||||
5:0/0 = 0
|
5:0/0 = 0
|
||||||
|
5:0/0/custom_data_0 = true
|
||||||
6:0/0 = 0
|
6:0/0 = 0
|
||||||
6:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
|
6:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
|
||||||
4:1/0 = 0
|
4:1/0 = 0
|
||||||
|
4:1/0/custom_data_0 = true
|
||||||
5:1/0 = 0
|
5:1/0 = 0
|
||||||
6:1/0 = 0
|
6:1/0 = 0
|
||||||
6:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
|
6:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
|
||||||
|
@ -28,14 +32,26 @@ texture_region_size = Vector2i(8, 8)
|
||||||
2:0/animation_mode = 1
|
2:0/animation_mode = 1
|
||||||
2:0/0 = 0
|
2:0/0 = 0
|
||||||
2:0/0/probability = 0.5
|
2:0/0/probability = 0.5
|
||||||
|
2:0/0/custom_data_0 = true
|
||||||
3:0/animation_columns = 1
|
3:0/animation_columns = 1
|
||||||
3:0/animation_mode = 1
|
3:0/animation_mode = 1
|
||||||
3:0/animation_frame_0/duration = 1.0
|
3:0/animation_frame_0/duration = 1.0
|
||||||
3:0/animation_frame_1/duration = 1.0
|
3:0/animation_frame_1/duration = 1.0
|
||||||
3:0/0 = 0
|
3:0/0 = 0
|
||||||
3:0/0/probability = 0.2
|
3:0/0/probability = 0.2
|
||||||
|
3:0/0/custom_data_0 = true
|
||||||
|
0:6/0 = 0
|
||||||
|
1:6/0 = 0
|
||||||
|
2:6/0 = 0
|
||||||
|
1:7/0 = 0
|
||||||
|
0:7/0 = 0
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
tile_size = Vector2i(8, 8)
|
tile_size = Vector2i(8, 8)
|
||||||
physics_layer_0/collision_layer = 1
|
physics_layer_0/collision_layer = 1
|
||||||
|
physics_layer_1/collision_layer = 1
|
||||||
|
custom_data_layer_0/name = "walkable"
|
||||||
|
custom_data_layer_0/type = 1
|
||||||
|
custom_data_layer_1/name = "death"
|
||||||
|
custom_data_layer_1/type = 1
|
||||||
sources/0 = SubResource("TileSetAtlasSource_m1u1u")
|
sources/0 = SubResource("TileSetAtlasSource_m1u1u")
|
||||||
|
|
Before Width: | Height: | Size: 578 B After Width: | Height: | Size: 701 B |