Love.Draw problem
Posted: Mon Aug 19, 2013 3:32 am
--excuse the messy file name
What im currently working on is simplified version of bomberman (^_^ awesome game) and i cant figure out how to spawn a bomb
In my love.load i have 2 objects player.ball and player.bomb
in my love.update i have controls for the player.ball and if space is pressed i change a state into true
and finally in love.draw i want to make it so only when 'space' is down it will draw the player.bomb
What im currently working on is simplified version of bomberman (^_^ awesome game) and i cant figure out how to spawn a bomb
In my love.load i have 2 objects player.ball and player.bomb
Code: Select all
player = {}
player.ball= {}
player.ball.body = love.physics.newBody(world,650/2,1200/2,'dynamic') -- player Ball
player.ball.shape = love.physics.newCircleShape(20) --20 radius
player.ball.fixture = love.physics.newFixture(player.ball.body, player.ball.shape)
player.bomb = {}
player.bomb.body = player.ball.body
player.bomb.shape = love.physics.newCircleShape(10)
player.bomb.fixture = love.physics.newFixture(player.bomb.body, player.bomb.shape)
Code: Select all
function love.update(dt)
world:update(dt)
if love.keyboard.isDown ('left') then
player.ball.body:applyForce(-400,0)
elseif love.keyboard.isDown ('right') then
player.ball.body:applyForce(400,0)
elseif love.keyboard.isDown ('up') then
player.ball.body:applyForce (0,-400)
elseif love.keyboard.isDown ('down') then
player.ball.body:applyForce (0,400)
elseif love.keyboard.isDown (' ') then
bombstate = yes
end
end
Code: Select all
function love.draw()
love.graphics.setColor (0,255,0)
love.graphics.polygon('fill',wall.ground.body:getWorldPoints(wall.ground.shape:getPoints()))
if bombstate == yes then
love.graphics.circle('fill', player.bomb.body:getX(), player.bomb.body:getY(), player.bomb.shape:getRadius())
end
love.graphics.setColor (0,0,0)
love.graphics.polygon('fill',wall.roof.body:getWorldPoints(wall.roof.shape:getPoints()))
love.graphics.polygon('fill', wall.left.body:getWorldPoints(wall.left.shape:getPoints()))
love.graphics.polygon('fill', wall.right.body:getWorldPoints(wall.right.shape:getPoints()))
love.graphics.polygon('fill', objects.onepointone.body:getWorldPoints(objects.onepointone.shape:getPoints()))
love.graphics.polygon ('fill', objects.onepointtwo.body:getWorldPoints(objects.onepointtwo.shape:getPoints()))
love.graphics.setColor(255,0,0)
love.graphics.circle('fill', player.ball.body:getX(), player.ball.body:getY(), player.ball.shape:getRadius())
end