Added the last 2 rooms and their puzzles
parent
f7d3ad7fa3
commit
23b26d0f35
|
@ -1,11 +1,13 @@
|
|||
class_name Player
|
||||
extends CharacterBody2D
|
||||
|
||||
@onready var death_sfx = preload("res://scenes/assets/jingles/fail.wav")
|
||||
@onready var raycast: RayCast2D = $RayCast2D
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var map: MainLevel = get_tree().root.get_child(0).get_node("TileMap")
|
||||
@onready var tile_map: TileMapLayer = get_tree().root.get_child(0).get_node("TileMap/TileMapLayer")
|
||||
@onready var camera: Camera2D = $Sprite2D/Camera2D
|
||||
@onready var camera: Camera2D = $AnimatedSprite2D/Camera2D
|
||||
@onready var audio_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
|
||||
@onready var start_point: Node2D = get_tree().root.get_child(0).get_node("Start")
|
||||
|
||||
const TILE_SIZE = 8
|
||||
|
@ -131,6 +133,8 @@ func die():
|
|||
is_dead = true
|
||||
is_moving = false
|
||||
respawn_time = 10
|
||||
audio_player.stream = death_sfx
|
||||
audio_player.play()
|
||||
|
||||
func apply_camera_shake(strength: float = 10.0, fade: float = 5.0):
|
||||
camera_shake = strength
|
||||
|
|
|
@ -213,7 +213,7 @@ script = ExtResource("1_jrd75")
|
|||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_icodh")
|
||||
animation = &"move_up"
|
||||
animation = &"move_down"
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="AnimatedSprite2D"]
|
||||
|
||||
|
|
|
@ -21,6 +21,10 @@ window/size/viewport_width=160
|
|||
window/size/viewport_height=144
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[global_group]
|
||||
|
||||
death=""
|
||||
|
||||
[input]
|
||||
|
||||
move_up={
|
||||
|
|
|
@ -6,18 +6,22 @@ extends StaticBody2D
|
|||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var map: MainLevel = get_tree().root.get_child(0).get_node("TileMap")
|
||||
@onready var tile_map: TileMapLayer = get_tree().root.get_child(0).get_node("TileMap/TileMapLayer")
|
||||
@onready var puzzle: BallCoursePuzzle = $"../"
|
||||
|
||||
@export var start_position: Node2D
|
||||
@export var movement_dir: Vector2 = Vector2(0, 0)
|
||||
var can_roll := false
|
||||
@export var puzzle: BallCoursePuzzle
|
||||
@export var can_roll := false
|
||||
@export var speed := 0.35
|
||||
var input_dir: Vector2
|
||||
var is_moving := false
|
||||
var _default_can_roll := false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
reset()
|
||||
input_dir = movement_dir.normalized()
|
||||
_default_can_roll = can_roll
|
||||
animation_player.speed_scale = (speed / 0.4) * input_dir.x
|
||||
reset()
|
||||
|
||||
func _physics_process(delta):
|
||||
_try_move(delta)
|
||||
|
@ -61,17 +65,18 @@ func _try_move(delta: int):
|
|||
if not is_moving:
|
||||
return
|
||||
|
||||
sprite.global_position = sprite.global_position.move_toward(global_position, 0.35)
|
||||
sprite.global_position = sprite.global_position.move_toward(global_position, speed)
|
||||
|
||||
if global_position == sprite.global_position:
|
||||
is_moving = false
|
||||
return
|
||||
|
||||
func reset():
|
||||
can_roll = false
|
||||
can_roll = _default_can_roll
|
||||
animation_player.stop()
|
||||
global_position = start_position.global_position
|
||||
|
||||
func _on_area_entered(area: Area2D):
|
||||
if area.is_in_group("death"):
|
||||
puzzle.reset()
|
||||
if puzzle:
|
||||
puzzle.reset()
|
||||
|
|
|
@ -24,6 +24,7 @@ tracks/0/keys = {
|
|||
resource_name = "roll"
|
||||
length = 3.0
|
||||
loop_mode = 1
|
||||
step = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
|
@ -68,7 +69,7 @@ shape = SubResource("RectangleShape2D_we7nh")
|
|||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||
target_position = Vector2(8, 0)
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["death"]]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("CircleShape2D_eid6d")
|
||||
|
|
|
@ -3,12 +3,16 @@ extends PuzzleManager
|
|||
@onready var player: Player = get_tree().root.get_child(0).get_node("Player")
|
||||
|
||||
@export var ball_puzzle_elements: Array[Node2D]
|
||||
@export var next_room_block: Node2D
|
||||
|
||||
func _on_finish_room():
|
||||
pass
|
||||
|
||||
|
||||
func _on_ball_puzzle_complete_puzzle():
|
||||
player.apply_camera_shake(10, 5)
|
||||
for elem in ball_puzzle_elements:
|
||||
elem.queue_free()
|
||||
|
||||
|
||||
func _on_box_puzzle_complete_puzzle():
|
||||
next_room_block.queue_free()
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
extends PuzzleManager
|
||||
|
||||
@export var next_room_wall: Node2D
|
||||
@export var box_puzzle_light: Sprite2D
|
||||
@export var grave_puzzle_light: Sprite2D
|
||||
|
||||
func _on_finish_room():
|
||||
next_room_wall.queue_free()
|
||||
|
||||
func _on_box_puzzle_complete_puzzle():
|
||||
box_puzzle_light.frame = 17
|
||||
|
||||
func _on_grave_puzzle_complete_puzzle():
|
||||
grave_puzzle_light.frame = 17
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dyedtl8nglwcl"]
|
||||
|
||||
[ext_resource type="Script" path="res://puzzles/teleporter/teleporter.gd" id="1_es25x"]
|
||||
[ext_resource type="Texture2D" uid="uid://cbuibrshdpkm1" path="res://scenes/assets/tileset.png" id="2_exrnf"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kuq27"]
|
||||
size = Vector2(6, 5)
|
||||
|
||||
[node name="WallOpening" type="Area2D"]
|
||||
script = ExtResource("1_es25x")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_exrnf")
|
||||
hframes = 8
|
||||
vframes = 8
|
||||
frame = 7
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 0.5)
|
||||
shape = SubResource("RectangleShape2D_kuq27")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
421
scenes/main.tscn
421
scenes/main.tscn
File diff suppressed because one or more lines are too long
Reference in New Issue