Compare commits
3 commits
e33cc17bc2
...
425053b4b2
| Author | SHA1 | Date | |
|---|---|---|---|
| 425053b4b2 | |||
| cb2e88bf3e | |||
| 46536f02b8 |
7 changed files with 83 additions and 21 deletions
7
board.gd
7
board.gd
|
|
@ -9,6 +9,13 @@ extends Node3D
|
||||||
# literally just linearly search to find pieces at a position
|
# literally just linearly search to find pieces at a position
|
||||||
# children
|
# children
|
||||||
|
|
||||||
|
# for zooming out to see the whole puzzle
|
||||||
|
func top_left_aabb() -> AABB:
|
||||||
|
return AABB(position, Vector3.ONE*0.1)
|
||||||
|
|
||||||
|
func bottom_right_aabb() -> AABB:
|
||||||
|
return AABB(position + Vector3(dims.x, 0, dims.y), Vector3.ONE*0.1)
|
||||||
|
|
||||||
# todo: Array[Piece]
|
# todo: Array[Piece]
|
||||||
func pieces() -> Array:
|
func pieces() -> Array:
|
||||||
return get_children()
|
return get_children()
|
||||||
|
|
|
||||||
47
main.gd
47
main.gd
|
|
@ -17,30 +17,23 @@ var hist := UndoRedo.new()
|
||||||
var player: Piece
|
var player: Piece
|
||||||
|
|
||||||
@onready var sound: AudioStreamPlayer = $Sound
|
@onready var sound: AudioStreamPlayer = $Sound
|
||||||
var sounds_hit := AudioStreamRandomizer.new()
|
@onready var sounds_hit := audio_stream_randomizer_from_dir("res://sfx/hit")
|
||||||
|
@onready var sounds_undo := audio_stream_randomizer_from_dir("res://sfx/undo")
|
||||||
|
@onready var sounds_redo := audio_stream_randomizer_from_dir("res://sfx/redo")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_child(board)
|
add_child(board)
|
||||||
var wall_count := 0
|
|
||||||
var wall_pos_sum := Vector2.ZERO
|
|
||||||
for piece in board.pieces():
|
for piece in board.pieces():
|
||||||
if piece.type == Piece.Type.Player:
|
if piece.type == Piece.Type.Player:
|
||||||
player = piece
|
player = piece
|
||||||
elif piece.type == Piece.Type.Wall:
|
$TopLeft.aabb = board.top_left_aabb()
|
||||||
wall_count += 1
|
$BottomRight.aabb = board.bottom_right_aabb()
|
||||||
wall_pos_sum += Vector2(piece.position.x, piece.position.z)
|
camera.position = Vector3(player.position.x, camera.position.y, player.position.z)
|
||||||
var wall_pos_mean := wall_pos_sum / wall_count
|
|
||||||
camera.position = Vector3(wall_pos_mean.x, camera.position.y, wall_pos_mean.y)
|
|
||||||
|
|
||||||
sounds_hit.random_pitch = 1.1
|
func _process(delta: float) -> void:
|
||||||
var hit_dir := DirAccess.open("res://sfx/hit")
|
if $TopLeft.is_on_screen() and $BottomRight.is_on_screen():
|
||||||
hit_dir.list_dir_begin()
|
return
|
||||||
var file_name := hit_dir.get_next()
|
camera.position.y += delta
|
||||||
while file_name != "":
|
|
||||||
if file_name.ends_with("ogg"):
|
|
||||||
var stream := AudioStream.new()
|
|
||||||
sounds_hit.add_stream(-1, load("res://sfx/hit/"+file_name))
|
|
||||||
file_name = hit_dir.get_next()
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("u", true, true):
|
if event.is_action_pressed("u", true, true):
|
||||||
|
|
@ -52,9 +45,13 @@ func _input(event: InputEvent) -> void:
|
||||||
elif event.is_action_pressed("r", true, true):
|
elif event.is_action_pressed("r", true, true):
|
||||||
step(Vector2i.RIGHT)
|
step(Vector2i.RIGHT)
|
||||||
elif event.is_action_pressed("undo", true, true):
|
elif event.is_action_pressed("undo", true, true):
|
||||||
hist.undo()
|
if hist.undo():
|
||||||
|
sound.stream = sounds_undo
|
||||||
|
sound.play()
|
||||||
elif event.is_action_pressed("redo", true, true):
|
elif event.is_action_pressed("redo", true, true):
|
||||||
hist.redo()
|
if hist.redo():
|
||||||
|
sound.stream = sounds_redo
|
||||||
|
sound.play()
|
||||||
elif event.is_action_pressed("restart", true, true):
|
elif event.is_action_pressed("restart", true, true):
|
||||||
restart()
|
restart()
|
||||||
|
|
||||||
|
|
@ -80,3 +77,15 @@ func step(move: Vector2i):
|
||||||
else:
|
else:
|
||||||
sound.stream = sounds_hit
|
sound.stream = sounds_hit
|
||||||
sound.play()
|
sound.play()
|
||||||
|
|
||||||
|
func audio_stream_randomizer_from_dir(dir: String) -> AudioStreamRandomizer:
|
||||||
|
var stream := AudioStreamRandomizer.new()
|
||||||
|
stream.random_pitch = 1.1
|
||||||
|
var hit_dir := DirAccess.open(dir)
|
||||||
|
hit_dir.list_dir_begin()
|
||||||
|
var file_name := hit_dir.get_next()
|
||||||
|
while file_name != "":
|
||||||
|
if file_name.ends_with("ogg"):
|
||||||
|
stream.add_stream(-1, load(dir+"/"+file_name))
|
||||||
|
file_name = hit_dir.get_next()
|
||||||
|
return stream
|
||||||
|
|
|
||||||
10
main.tscn
10
main.tscn
|
|
@ -16,10 +16,18 @@ sky = SubResource("Sky_0xm2m")
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
|
|
||||||
[node name="Camera" type="Camera3D" parent="."]
|
[node name="Camera" type="Camera3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 5, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.5, 0)
|
||||||
fov = 90.0
|
fov = 90.0
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource("Environment_ig7tw")
|
environment = SubResource("Environment_ig7tw")
|
||||||
|
|
||||||
[node name="Sound" type="AudioStreamPlayer" parent="."]
|
[node name="Sound" type="AudioStreamPlayer" parent="."]
|
||||||
|
|
||||||
|
[node name="TopLeft" type="VisibleOnScreenNotifier3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.5, 0, -0.25)
|
||||||
|
aabb = AABB(-0.25, 0, -0.25, 2, 2, 2)
|
||||||
|
|
||||||
|
[node name="BottomRight" type="VisibleOnScreenNotifier3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 0, 0.25)
|
||||||
|
aabb = AABB(0, 0, 0, 2, 2, 2)
|
||||||
|
|
|
||||||
BIN
sfx/redo/jingles-saxophone_15.ogg
Normal file
BIN
sfx/redo/jingles-saxophone_15.ogg
Normal file
Binary file not shown.
19
sfx/redo/jingles-saxophone_15.ogg.import
Normal file
19
sfx/redo/jingles-saxophone_15.ogg.import
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://yckyg3m66h1u"
|
||||||
|
path="res://.godot/imported/jingles-saxophone_15.ogg-75960c939c728136300eb69e1176d924.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sfx/redo/jingles-saxophone_15.ogg"
|
||||||
|
dest_files=["res://.godot/imported/jingles-saxophone_15.ogg-75960c939c728136300eb69e1176d924.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
BIN
sfx/undo/jingles-saxophone_16.ogg
Normal file
BIN
sfx/undo/jingles-saxophone_16.ogg
Normal file
Binary file not shown.
19
sfx/undo/jingles-saxophone_16.ogg.import
Normal file
19
sfx/undo/jingles-saxophone_16.ogg.import
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://cs2drft1a74sw"
|
||||||
|
path="res://.godot/imported/jingles-saxophone_16.ogg-2a826dd03c8724fa27e6b96d58aa50df.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sfx/undo/jingles-saxophone_16.ogg"
|
||||||
|
dest_files=["res://.godot/imported/jingles-saxophone_16.ogg-2a826dd03c8724fa27e6b96d58aa50df.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
Loading…
Reference in a new issue