I have this error CONSTANTLY and I'm really getting sick of it.
Code: Select all
function love.load()
love.physics.setMeter(60)
world = love.physics.newWorld(0, 9.81*64, true)
--image = love.graphics.newImage("sheet1.png")
--x = 50
--y = 50
--speed = 100
player = {}
player.image = love.graphics.newImage("sheet1.png")
player.left1 = love.graphics.newQuad(10, 30, 91, 170, 550, 170) --(10, 30, 91, 170, 550, 170)
objects = {} --Creates table "objects"
--The ground
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 650/2, 650-50/2) --2nd & 3rd parameter are used to anchor object.ground to fit in correct place
objects.ground.shape = love.physics.newRectangleShape(650, 50) --Width = 650, Height = 50
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape) --attach shape to body
--Ball
objects.ball = {}
objects.ball.body = love.physics.newBody(world, 650/2, 650/2, "dynamic") -- Centering of the ball, made to be dynamic to move.
objects.ball.shape = love.physics.newCircleShape(20) -- Radius = 20
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1)
objects.ball.fixture:setRestitution(0.9) --Adds le bounce
--Blocks
objects.block1 = {}
objects.block1.body = love.physics.newBody(world, 200, 550, "dynamic")
objects.block1.shape = love.physics.newRectangleShape(0, 0, 50, 100)
objects.block1.fixture = love.physics.newFixture(objects.block1.body, objects.block1.shape, 5)
objects.block2 = {}
objects.block2.body = love.physics.newBody(world, 200, 400, "dynamic")
objects.block2.shape = love.physics.newRectangleShape(0, 0, 100, 50)
objects.block2.fixture = love.physics.newFixture(objects.block2.body, objects.block2.shape, 2)
objects.player = {}
objects.player.body = love.physics.newBody(world, 10, 30, "dynamic")
objects.player.shape = love.physics newRectangleShape(10, 30, 91, 170)
objects.player.fixture = love.physics.newFixture(objects.player.body, objects.player.shape)
love.graphics.setBackgroundColor(101, 64, 251) --Blue background!
love.graphics.setMode(650, 650, false, true, 0) --set the window dimensions to 650 by 650 with no fullscreen, vsync on, and no antialiasing
end
function love.update(dt)
world:update(dt) --this puts the world into motion
if love.keyboard.isDown("right") then --press the right arrow key to push the ball to the right
objects.ball.body:applyForce(400, 0)
elseif love.keyboard.isDown("left") then --press the left arrow key to push the ball to the left
objects.ball.body:applyForce(-400, 0)
elseif love.keyboard.isDown("up") then --press the up arrow key to set the ball in the air
objects.ball.body:setPosition(650/2, 650/2)
end
end
function love.draw()
love.graphics.setCaption("Mars")
--love.graphics.draw(image, sheet1.png, 50, 50)
love.graphics.drawq(player.image, player.left1, 100, 100)
love.graphics.setColor(72, 160, 14) -- set the drawing color to green for the ground
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints())) -- draw a "filled in" polygon using the ground's coordinates
love.graphics.setColor(193, 47, 14) --set the drawing color to red for the ball
love.graphics.circle("fill", objects.ball.body:getX(), objects.ball.body:getY(), objects.ball.shape:getRadius())
love.graphics.setColor(50, 50, 50) -- set the drawing color to grey for the blocks
love.graphics.polygon("fill", objects.block1.body:getWorldPoints(objects.block1.shape:getPoints()))
love.graphics.polygon("fill", objects.block2.body:getWorldPoints(objects.block2.shape:getPoints()))
end