diff options
-rw-r--r-- | data/crate_move.wav | bin | 0 -> 102444 bytes | |||
-rw-r--r-- | data/move.wav | bin | 0 -> 48932 bytes | |||
-rw-r--r-- | data/restart.wav | bin | 0 -> 59746 bytes | |||
-rw-r--r-- | data/undo.wav | bin | 0 -> 9950 bytes | |||
-rw-r--r-- | data/win.wav | bin | 0 -> 397116 bytes | |||
-rw-r--r-- | main.lua | 22 |
6 files changed, 21 insertions, 1 deletions
diff --git a/data/crate_move.wav b/data/crate_move.wav Binary files differnew file mode 100644 index 0000000..e8fa8b9 --- /dev/null +++ b/data/crate_move.wav diff --git a/data/move.wav b/data/move.wav Binary files differnew file mode 100644 index 0000000..04ff3f6 --- /dev/null +++ b/data/move.wav diff --git a/data/restart.wav b/data/restart.wav Binary files differnew file mode 100644 index 0000000..932004b --- /dev/null +++ b/data/restart.wav diff --git a/data/undo.wav b/data/undo.wav Binary files differnew file mode 100644 index 0000000..64e4567 --- /dev/null +++ b/data/undo.wav diff --git a/data/win.wav b/data/win.wav Binary files differnew file mode 100644 index 0000000..89233dd --- /dev/null +++ b/data/win.wav @@ -35,6 +35,13 @@ function love.load() goal = love.graphics.newImage("data/goal.png") crate_goal = love.graphics.newImage("data/crate_goal.png") + -- load sounds + move_sound = love.audio.newSource("data/move.wav", "static") + crate_sound = love.audio.newSource("data/crate_move.wav", "static") + undo_sound = love.audio.newSource("data/undo.wav", "static") + restart_sound = love.audio.newSource("data/restart.wav", "static") + win_sound = love.audio.newSource("data/win.wav", "static") + player_frames = { love.graphics.newImage("data/player_01.png"), love.graphics.newImage("data/player_02.png") @@ -107,6 +114,7 @@ function move(target_x, target_y) end end + local playing = false -- pushing a box if destination == '$' or destination == '*' then local destination_crate = level[player_y + target_y * 2][player_x + target_x * 2] @@ -127,6 +135,9 @@ function move(target_x, target_y) else level[player_y + target_y * 2][player_x + target_x * 2] = '*' end + + playing = true + crate_sound:play() else -- we can't, so we don't move return @@ -151,6 +162,10 @@ function move(target_x, target_y) player_y = player_y + target_y moves = moves + 1 + if playing == false then + move_sound:play() + end + -- save the previous move for UNDO table.insert(state_undo, 1, {undo, undo_x, undo_y}) end @@ -173,8 +188,9 @@ end -- keypressed handler during play function keypressed_play(key) if key == "r" then - -- reset level + -- restart level set_level(current_level) + restart_sound:play() return elseif key == "u" and #state_undo > 0 then -- undo move @@ -183,6 +199,7 @@ function keypressed_play(key) player_x = state[2] player_y = state[3] moves = moves - 1 + undo_sound:play() end -- where are we moving @@ -294,6 +311,9 @@ function love.draw() if state == "win" then if win_delay < 64 then win_delay = win_delay + 1 + if win_delay == 64 then + win_sound:play() + end else love.graphics.setColor(0.3, 0.3, 0.5) love.graphics.rectangle("fill", 0, 80 * game.scale, game.width * game.scale, 60 * game.scale) |