Compare commits
No commits in common. "425053b4b2b2ce20336b8167400a369fb3a00ed3" and "e33cc17bc2891aaa4dd565f5f6d7217ae63c8b96" have entirely different histories.
425053b4b2
...
e33cc17bc2
7 changed files with 21 additions and 83 deletions
7
board.gd
7
board.gd
|
|
@ -9,13 +9,6 @@ extends Node3D
|
|||
# literally just linearly search to find pieces at a position
|
||||
# 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]
|
||||
func pieces() -> Array:
|
||||
return get_children()
|
||||
|
|
|
|||
49
main.gd
49
main.gd
|
|
@ -17,23 +17,30 @@ var hist := UndoRedo.new()
|
|||
var player: Piece
|
||||
|
||||
@onready var sound: AudioStreamPlayer = $Sound
|
||||
@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")
|
||||
var sounds_hit := AudioStreamRandomizer.new()
|
||||
|
||||
func _ready() -> void:
|
||||
add_child(board)
|
||||
var wall_count := 0
|
||||
var wall_pos_sum := Vector2.ZERO
|
||||
for piece in board.pieces():
|
||||
if piece.type == Piece.Type.Player:
|
||||
player = piece
|
||||
$TopLeft.aabb = board.top_left_aabb()
|
||||
$BottomRight.aabb = board.bottom_right_aabb()
|
||||
camera.position = Vector3(player.position.x, camera.position.y, player.position.z)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if $TopLeft.is_on_screen() and $BottomRight.is_on_screen():
|
||||
return
|
||||
camera.position.y += delta
|
||||
elif piece.type == Piece.Type.Wall:
|
||||
wall_count += 1
|
||||
wall_pos_sum += Vector2(piece.position.x, piece.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
|
||||
var hit_dir := DirAccess.open("res://sfx/hit")
|
||||
hit_dir.list_dir_begin()
|
||||
var file_name := hit_dir.get_next()
|
||||
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:
|
||||
if event.is_action_pressed("u", true, true):
|
||||
|
|
@ -45,13 +52,9 @@ func _input(event: InputEvent) -> void:
|
|||
elif event.is_action_pressed("r", true, true):
|
||||
step(Vector2i.RIGHT)
|
||||
elif event.is_action_pressed("undo", true, true):
|
||||
if hist.undo():
|
||||
sound.stream = sounds_undo
|
||||
sound.play()
|
||||
hist.undo()
|
||||
elif event.is_action_pressed("redo", true, true):
|
||||
if hist.redo():
|
||||
sound.stream = sounds_redo
|
||||
sound.play()
|
||||
hist.redo()
|
||||
elif event.is_action_pressed("restart", true, true):
|
||||
restart()
|
||||
|
||||
|
|
@ -77,15 +80,3 @@ func step(move: Vector2i):
|
|||
else:
|
||||
sound.stream = sounds_hit
|
||||
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,18 +16,10 @@ sky = SubResource("Sky_0xm2m")
|
|||
script = ExtResource("1_ig7tw")
|
||||
|
||||
[node name="Camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.5, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 5, 0)
|
||||
fov = 90.0
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_ig7tw")
|
||||
|
||||
[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)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,19 +0,0 @@
|
|||
[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
|
||||
Binary file not shown.
|
|
@ -1,19 +0,0 @@
|
|||
[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