Develop #4
@@ -3,11 +3,12 @@ local tools = require 'assets/scripts/tools'
|
|||||||
local HC = require 'assets/scripts/vendor/HC'
|
local HC = require 'assets/scripts/vendor/HC'
|
||||||
|
|
||||||
local bell = {}
|
local bell = {}
|
||||||
local collision_debug = true
|
local collision_debug = false
|
||||||
local collisions = {}
|
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')
|
||||||
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,
|
||||||
@@ -16,7 +17,7 @@ function bell.load(game, cam)
|
|||||||
y = -game.canvas.height
|
y = -game.canvas.height
|
||||||
}
|
}
|
||||||
g = anim8.newGrid(body.img:getWidth() / body.num_frames, body.img:getHeight(), body.img:getWidth(), body.img:getHeight())
|
g = anim8.newGrid(body.img:getWidth() / body.num_frames, body.img:getHeight(), body.img:getWidth(), body.img:getHeight())
|
||||||
body.animation = anim8.newAnimation(g('1-' .. body.num_frames, 1), body.speed, 'pauseAtEnd')
|
body.animation = anim8.newAnimation(g('1-' .. body.num_frames, 1), body.speed)
|
||||||
body.animation:pause()
|
body.animation:pause()
|
||||||
|
|
||||||
cam_x, cam_y = cam.gcam:getVisible()
|
cam_x, cam_y = cam.gcam:getVisible()
|
||||||
@@ -85,8 +86,6 @@ function bell.update(dt, game, cam)
|
|||||||
for key, item in pairs(bell.enable) do
|
for key, item in pairs(bell.enable) do
|
||||||
-- Count enables
|
-- Count enables
|
||||||
num_enable = num_enable + 1
|
num_enable = num_enable + 1
|
||||||
-- if key == 1 and item and bell.enable[tools.table_length(bell.enable)] == false then
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
if num_enable > 1 then
|
if num_enable > 1 then
|
||||||
-- Search emptys
|
-- Search emptys
|
||||||
@@ -96,11 +95,29 @@ function bell.update(dt, game, cam)
|
|||||||
count_singles = count_singles + 1
|
count_singles = count_singles + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Bad. Restart
|
||||||
if count_singles >= 2 then
|
if count_singles >= 2 then
|
||||||
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
|
||||||
end
|
end
|
||||||
|
-- Check good
|
||||||
|
local good = true
|
||||||
|
for key, item in pairs(bell.enable) do
|
||||||
|
if bell.enable[key] == false then
|
||||||
|
good = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Enable animation good
|
||||||
|
if good then
|
||||||
|
bell.animation:resume()
|
||||||
|
sound_1:stop()
|
||||||
|
sound_1:play()
|
||||||
|
for key, item in pairs(bell.enable) do
|
||||||
|
bell.enable[key] = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
good = true
|
||||||
count_singles = 0
|
count_singles = 0
|
||||||
end
|
end
|
||||||
num_enable = 0
|
num_enable = 0
|
||||||
|
|||||||
@@ -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 = true
|
bells_enable = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function game:nextLevel()
|
function game:nextLevel()
|
||||||
|
|||||||
Reference in New Issue
Block a user