Develop #4

Merged
wariosolis merged 35 commits from develop into master 2017-01-04 00:04:34 +01:00
12 changed files with 49 additions and 11 deletions
Showing only changes of commit 30630b33ef - Show all commits
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+39 -10
View File
@@ -8,11 +8,12 @@ local collisions = {}
local cam_x, cam_y = nil local cam_x, cam_y = nil
function bell.load(game, cam) function bell.load(game, cam)
sound_1 = love.audio.newSource('assets/audio/fx/bill_1.wav', 'static') sound_error = love.audio.newSource('assets/audio/fx/bills/campana_fallo.wav', 'static')
body = { body = {
img = love.graphics.newImage('assets/sprites/bells/bell_vibrate.png'), img = love.graphics.newImage('assets/sprites/bells/bell_vibrate.png'),
num_frames = 10, num_frames = 10,
speed = 0.05, speed = 0.05,
active = false,
x = -game.canvas.width, x = -game.canvas.width,
y = -game.canvas.height y = -game.canvas.height
} }
@@ -24,12 +25,18 @@ function bell.load(game, cam)
bell_1 = tools.clone_table(body) bell_1 = tools.clone_table(body)
bell_1.x = cam_x + (game.window.width / 4) - (bell_1.img:getWidth() / body.num_frames / 2) bell_1.x = cam_x + (game.window.width / 4) - (bell_1.img:getWidth() / body.num_frames / 2)
bell_1.y = (game.window.height / 2) - (bell_1.img:getHeight() / 2) bell_1.y = (game.window.height / 2) - (bell_1.img:getHeight() / 2)
bell_1.sound_loop = love.audio.newSource('assets/audio/fx/bills/campana_loop1.wav', 'static')
bell_1.sound_good = love.audio.newSource('assets/audio/fx/bills/campana_exito1.wav', 'static')
bell_2 = tools.clone_table(body) bell_2 = tools.clone_table(body)
bell_2.x = cam_x + (game.window.width / 4 * 2) - (bell_1.img:getWidth() / body.num_frames / 2) bell_2.x = cam_x + (game.window.width / 4 * 2) - (bell_1.img:getWidth() / body.num_frames / 2)
bell_2.y = bell_1.y bell_2.y = bell_1.y
bell_2.sound_loop = love.audio.newSource('assets/audio/fx/bills/campana_loop2.wav', 'static')
bell_2.sound_good = love.audio.newSource('assets/audio/fx/bills/campana_exito2.wav', 'static')
bell_3 = tools.clone_table(body) bell_3 = tools.clone_table(body)
bell_3.x = cam_x + (game.window.width / 4 * 3) - (bell_1.img:getWidth() / body.num_frames / 2) bell_3.x = cam_x + (game.window.width / 4 * 3) - (bell_1.img:getWidth() / body.num_frames / 2)
bell_3.y = bell_1.y bell_3.y = bell_1.y
bell_3.sound_loop = love.audio.newSource('assets/audio/fx/bills/campana_loop3.wav', 'static')
bell_3.sound_good = love.audio.newSource('assets/audio/fx/bills/campana_exito3.wav', 'static')
bells = {bell_1, bell_2, bell_3} bells = {bell_1, bell_2, bell_3}
-- Collisions -- Collisions
@@ -73,11 +80,16 @@ function bell.update(dt, game, cam)
end end
end end
-- Check collisions -- Check collisions
for key, bell in pairs(bells) do if game.bells_enable then
for key, collision in pairs(bell.collisions) do for key, bell in pairs(bells) do
for shape, delta in pairs(HC.collisions(bell.collisions[key])) do for key, collision in pairs(bell.collisions) do
bell.enable[key] = true for shape, delta in pairs(HC.collisions(bell.collisions[key])) do
end if bell.sound_loop:isPlaying() == false then
bell.sound_loop:play()
end
bell.enable[key] = true
end
end
end end
end end
-- Logic -- Logic
@@ -97,6 +109,10 @@ function bell.update(dt, game, cam)
end end
-- Bad. Restart -- Bad. Restart
if count_singles >= 2 then if count_singles >= 2 then
for key, bell in pairs(bells) do
bell.sound_loop:stop()
end
sound_error:play()
for key, item in pairs(bell.enable) do for key, item in pairs(bell.enable) do
bell.enable[key] = false bell.enable[key] = false
end end
@@ -110,9 +126,9 @@ function bell.update(dt, game, cam)
end end
-- Enable animation good -- Enable animation good
if good then if good then
bell.active = true
bell.animation:resume() bell.animation:resume()
sound_1:stop() bell.sound_good:play()
sound_1:play()
for key, item in pairs(bell.enable) do for key, item in pairs(bell.enable) do
bell.enable[key] = false bell.enable[key] = false
end end
@@ -122,10 +138,23 @@ function bell.update(dt, game, cam)
end end
num_enable = 0 num_enable = 0
end end
-- Game over
game_over = true
for key, bell in pairs(bells) do
if not bell.active then
game_over = false
end
end
for key, bell in pairs(bells) do
if game_over then
bell.animation:pauseAtEnd()
game.bells_enable = false
end
end
end end
function bell.draw() function bell.draw(game)
if bells_enable then if game.bells_enable then
-- Bells -- Bells
for key, bell in pairs(bells) do for key, bell in pairs(bells) do
bell.animation:draw(bell.img, bell.x, bell.y) bell.animation:draw(bell.img, bell.x, bell.y)
+9 -1
View File
@@ -20,7 +20,7 @@ function game.load()
game.world = love.physics.newWorld(0, gravity * world_meter, true) -- Make earth game.world = love.physics.newWorld(0, gravity * world_meter, true) -- Make earth
-- Bells -- Bells
bells_enable = false game.bells_enable = true
game.music = love.audio.newSource("assets/audio/music/theme.mp3") game.music = love.audio.newSource("assets/audio/music/theme.mp3")
game:playMusic() game:playMusic()
@@ -29,6 +29,14 @@ function game.load()
end end
function game.update(dt)
if game.bells_enable then
game:stopMusic()
else
game:playMusic()
end
end
function game:nextLevel() function game:nextLevel()
if game.level == game.end_level then if game.level == game.end_level then
game.level = 1 game.level = 1
+1
View File
@@ -21,6 +21,7 @@ end
function love.update(dt) function love.update(dt)
require('assets/scripts/vendor/lovebird').update() require('assets/scripts/vendor/lovebird').update()
game.world:update(dt) game.world:update(dt)
game.update(dt)
camera.update(game) camera.update(game)
stages.update(dt, game, camera) stages.update(dt, game, camera)
stress.update(dt, game, camera) stress.update(dt, game, camera)