main
Code: Select all
require "Code/GameCode"
require "Levels/Level"
Code: Select all
--PlayersHealth = 100
local Move = 2.2
function love.update(dt)
World:update(dt)
----------------------------------------------------------------------------------
--movement
----------------------------------------------------------------------------------
--left
if love.keyboard.isDown("a") or love.keyboard.isDown("left") then
Players_x = Players_x - Move
end
--right
if love.keyboard.isDown("d") or love.keyboard.isDown("right")then
Players_x = Players_x + Move
end
--up
if love.keyboard.isDown("w") or love.keyboard.isDown("up")then
Players_y = Players_y - Move
end
--down
if love.keyboard.isDown("s") or love.keyboard.isDown("down")then
Players_y = Players_y + Move
end
-----------------------------------------------------------------------------------
--Health
-----------------------------------------------------------------------------------
end
Code: Select all
Players_x = 76
Players_y = 118
function love.load()
love.physics.setMeter( 4 )
World = love.physics.newWorld( 0, 500, true)
-------------------------------------------------------------------------
-- Player
PlayerSprite = love.graphics.newImage ("Sprites/Player/Player.png")
-- Player Physics
PlayerB = love.physics.newBody( World, Players_x, Players_y, "dynamic")
PlayerS = love.physics.newRectangleShape( 22, 34 )
PlayerF = love.physics.newFixture( PlayerB, PlayerS, 1)
-- Background
Background = love.graphics.newImage("Sprites/Background.png")
-------------------------------------------------------------------------
-- Physics
floor1B = love.physics.newBody( World, 61, 152, "static")
floor1S = love.physics.newRectangleShape( 300, 30)
floor1F = love.physics.newFixture( floor1B, floor1S, 1)
floor2B = love.physics.newBody( World, 435, 182, "static")
floor2S = love.physics.newRectangleShape( 300, 30)
floor2F = love.physics.newFixture( floor2B, floor2S, 1)
groundB = love.physics.newBody( World, 0, 570, "static")
groundS = love.physics.newRectangleShape( 800, 30)
groundF = love.physics.newFixture( groundB, groundS, 1)
end
function love.draw()
love.graphics.draw( Background, 0, 0)
love.graphics.draw (PlayerSprite, Players_x, Players_y)
end