animation indicator

This commit is contained in:
Andros Fenollosa 2017-01-05 11:53:52 +01:00
parent 815069d293
commit 52929bdd84
4 changed files with 34 additions and 4 deletions

View File

@ -11,6 +11,7 @@ function game.load()
love.window.setMode(game.window.width, game.window.height)
game.level = 1
game.play = true
game.die = false
-- Physics
DEBUG = true
local world_meter = 64
@ -19,4 +20,11 @@ function game.load()
game.world = love.physics.newWorld(0, gravity * world_meter, true) -- Make earth
end
function game.update(dt)
if game.die then
game.lifes = game.lifes - 1
game.die = false
end
end
return game

View File

@ -31,17 +31,37 @@ function life.load(game)
width = 10,
color = {0, 0, 0},
angle = 230,
move_up = false
move_up = false,
vel = 1
}
life.indicator.radius = tools.distance(life.indicator.x_shaft, life.indicator.y_shaft, life.indicator.x_target, life.indicator.y_target)
love.graphics.setLineWidth(life.indicator.width)
life.indicator.limits = {}
life.indicator.limits[2] = {
min = 260,
max = 270
}
life.indicator.limits[3] = {
min = 230,
max = 240
}
end
function life.update(dt, game)
life.top.animation:update(dt)
-- 1 230 240
if game.life == 3 then
end
-- Direction
if life.indicator.limits[game.lifes].max < life.indicator.angle then
life.indicator.move_up = false
elseif life.indicator.limits[game.lifes].min > life.indicator.angle then
life.indicator.move_up = true
end
-- Increment
if life.indicator.move_up then
life.indicator.angle = life.indicator.angle + life.indicator.vel
else
life.indicator.angle = life.indicator.angle - life.indicator.vel
end
-- Calculate pos indicator
life.indicator.x_target, life.indicator.y_target = tools.circle_position(life.indicator.angle, life.indicator.radius, life.indicator.x_shaft, life.indicator.y_shaft)
end

View File

@ -100,6 +100,7 @@ function spaceship.update(dt, game)
-- Check for collisions
for shape, delta in pairs(HC.collisions(body.collision.hc)) do
game.play = false
game.die = true
explosion.x, explosion.y, explosion.enable = body.body:getX() - explosion.claim_x, body.body:getY() - explosion.claim_y, true
explosion.animation:resume()
end

View File

@ -25,6 +25,7 @@ function love.update(dt)
require('assets/scripts/vendor/lovebird').update()
end
game.world:update(dt)
game.update(dt)
background.update(dt)
asteroids.update(dt, game)
moon.update()