Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x, y = 400, 100
- local vx, vy = 0, 0
- local gravity = 200
- local jumpspeed = 200
- local maxspeed = 300
- function love.update( dt )
- x = x + vx*dt
- y = y + vy*dt
- vy = vy + gravity*dt
- vx = vx * 0.9 -- Reibung
- if math.abs( vx ) < 10 then
- vx = 0
- end
- if y >= 500 then
- y = 500 -- nicht in den Boden fallen
- vy = 0
- end
- if love.keyboard.isDown( "left" ) then
- vx = -maxspeed
- elseif love.keyboard.isDown( "right" ) then
- vx = maxspeed
- end
- if love.keyboard.isDown( "up" ) and y >= 500 then
- vy = -jumpspeed
- end
- end
- function love.draw()
- love.graphics.circle( "fill", x, y, 10 )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement