I have no idea why the code would do this, but here it is just in case:
main
Code: Select all
require ("player")
local Quad = love.graphics.newQuad
function love.load()
love.physics.setMeter(60)
world = love.physics.newWorld(0, 9.81*64, true)
player_quad()
playerx = 400
playery = 400
objects = {} --Creates table "objects" sheet1.png
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
love.graphics.setBackgroundColor(25, 150, 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
player_update()
end
function love.draw()
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints())) -- draw a "filled in" polygon using the ground's coordinates
player_draw()
love.graphics.setColor(255, 255, 255) -- set the drawing color to green for the ground
end
Code: Select all
function player_quad() --Love.load only
sprite = love.graphics.newImage("graphics/fg4.png")
playerx = 50
playery = 50
left = {}
right = {}
--left
left[0] = love.graphics.newQuad(25,0,25,32,834,308);
left[1] = love.graphics.newQuad(0,0,25,32,834,308);
left[2] = love.graphics.newQuad(75,0,25,32,834,308);
--left[3] = love.graphics.newQuad(96, 48, 32, 48, 128, 192);
--right
--right[0] = love.graphics.newQuad( 0, 96, 32, 48, 128, 192);
--right[1] = love.graphics.newQuad(32, 96, 32, 48, 128, 192);
--right[2] = love.graphics.newQuad(64, 96, 32, 48, 128, 192);
--right[3] = love.graphics.newQuad(96, 96, 32, 48, 128, 192);
--iterator = 1
--max = 3
--timer = 1
--moving = false
--direction = "down"
end
function player_update()
if love.keyboard.isDown("right") then
playerx = playerx + 15
end
if love.keyboard.isDown("left") then
playerx = playerx - 15
end
if love.keyboard.isDown("up") then
playery = playery + 15
end
if love.keyboard.isDown("down") then
playery = playery - 15
end
end
function player_draw()
love.graphics.setColor(255,255,255)
love.graphics.drawq(sprite, left[0], playerx, playery)
end
Code: Select all
function love.conf(a)
a.screen.width = 800
a.screen.height = 800
a.title = -------
end