animation indicator
This commit is contained in:
parent
815069d293
commit
52929bdd84
@ -11,6 +11,7 @@ function game.load()
|
|||||||
love.window.setMode(game.window.width, game.window.height)
|
love.window.setMode(game.window.width, game.window.height)
|
||||||
game.level = 1
|
game.level = 1
|
||||||
game.play = true
|
game.play = true
|
||||||
|
game.die = false
|
||||||
-- Physics
|
-- Physics
|
||||||
DEBUG = true
|
DEBUG = true
|
||||||
local world_meter = 64
|
local world_meter = 64
|
||||||
@ -19,4 +20,11 @@ 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function game.update(dt)
|
||||||
|
if game.die then
|
||||||
|
game.lifes = game.lifes - 1
|
||||||
|
game.die = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return game
|
return game
|
@ -31,17 +31,37 @@ function life.load(game)
|
|||||||
width = 10,
|
width = 10,
|
||||||
color = {0, 0, 0},
|
color = {0, 0, 0},
|
||||||
angle = 230,
|
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)
|
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)
|
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
|
end
|
||||||
|
|
||||||
function life.update(dt, game)
|
function life.update(dt, game)
|
||||||
life.top.animation:update(dt)
|
life.top.animation:update(dt)
|
||||||
-- 1 230 240
|
-- Direction
|
||||||
if game.life == 3 then
|
if life.indicator.limits[game.lifes].max < life.indicator.angle then
|
||||||
end
|
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)
|
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
|
end
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ function spaceship.update(dt, game)
|
|||||||
-- Check for collisions
|
-- Check for collisions
|
||||||
for shape, delta in pairs(HC.collisions(body.collision.hc)) do
|
for shape, delta in pairs(HC.collisions(body.collision.hc)) do
|
||||||
game.play = false
|
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.x, explosion.y, explosion.enable = body.body:getX() - explosion.claim_x, body.body:getY() - explosion.claim_y, true
|
||||||
explosion.animation:resume()
|
explosion.animation:resume()
|
||||||
end
|
end
|
||||||
|
1
main.lua
1
main.lua
@ -25,6 +25,7 @@ function love.update(dt)
|
|||||||
require('assets/scripts/vendor/lovebird').update()
|
require('assets/scripts/vendor/lovebird').update()
|
||||||
end
|
end
|
||||||
game.world:update(dt)
|
game.world:update(dt)
|
||||||
|
game.update(dt)
|
||||||
background.update(dt)
|
background.update(dt)
|
||||||
asteroids.update(dt, game)
|
asteroids.update(dt, game)
|
||||||
moon.update()
|
moon.update()
|
||||||
|
Loading…
Reference in New Issue
Block a user