23 lines
649 B
Lua
23 lines
649 B
Lua
player = {}
|
|
-- Physics Engine
|
|
player.body = love.physics.newBody(myWorld, 100, 100, 'dynamic')
|
|
player.shape = love.physics.newRectangleShape(66, 92)
|
|
player.fixture = love.physics.newFixture(player.body, player.shape)
|
|
--
|
|
player.sprite = sprites.player_jump
|
|
player.speed = 200
|
|
player.grounded = false
|
|
player.direction = DIRECTION_RIGHT
|
|
|
|
function playerUpdate(dt)
|
|
if love.keyboard.isDown('a') then
|
|
player.body:setX(player.body:getX() - player.speed * dt)
|
|
player.direction = DIRECTION_LEFT
|
|
end
|
|
|
|
if love.keyboard.isDown('d') then
|
|
player.body:setX(player.body:getX() + player.speed * dt)
|
|
player.direction = DIRECTION_RIGHT
|
|
end
|
|
end
|