1234567891011121314151617181920212223242526272829303132333435363738 |
- function love.update(dt)
- world:update(dt) -- start the world
- love.graphics.print(player.body:getY(), canw/2, canv/2)
- love.graphics.print(platform.body:getY(), canw/3, canv/2)
- if love.keyboard.isDown("right") then
- plritate()
- if player.body:getX() < (love.graphics.getWidth() - player.img:getWidth()) then
- player.body:setLinearVelocity(player.speed,0+player.body:getY()/3 )
- end
-
- elseif love.keyboard.isDown("left") then
- plrotate()
- if player.x > 0 then
- player.body:setLinearVelocity(-player.speed,0+player.body:getY()/3 )
- end
- end
- if love.keyboard.isDown("space") then
- if player.body:getY() + 200 > platform.body:getY() then
- player.body:setLinearVelocity(0,player.jump)
- end
- end
- if love.keyboard.isDown("down") then
- player.body:setPosition(650/2, 650/2)
- -- reset velocity to 0
- player.body:setLinearVelocity(0, 0)
- end
- end
- function plrotate()
- player.img = love.graphics.newImage('images/tux1.png')
- end
- function plritate()
- player.img = love.graphics.newImage('images/tux.png')
- end
|