Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- background = {}
- background.image = love.graphics.newImage("background.png")
- ground = {}
- ground.image = love.graphics.newImage("ground.png")
- music = {}
- music.menu = love.audio.newSource("mainmenu.ogg",static)
- love.audio.play(music.menu)
- mouse = {}
- mouse.x = love.mouse.getX()
- mouse.y = love.mouse.getY()
- player = {}
- player.x = 300
- player.y = 327
- player.image = love.graphics.newImage("player.png")
- player.vel = {}
- player.vel.x = 0
- player.vel.y = 0
- landed = true
- menu = {}
- menu.image = love.graphics.newImage("ui/menu.png")
- pause = {}
- pause.image = love.graphics.newImage("ui/paused.png")
- play = false
- paused = false
- win = false
- playbutton = false
- pausebutton = false
- restartbutton = false
- start = false
- end
- function love.update(dt)
- mouse.x = love.mouse.getX()
- mouse.y = love.mouse.getY()
- if not play and not paused and not win and mouse.x > 286 and mouse.x < 993 and mouse.y > 86 and mouse.y < 736 then
- playbutton = true
- else
- playbutton = false
- end
- if play and start then
- love.audio.stop()
- start = false
- textactive = true
- end
- player.x = player.x + player.vel.x
- player.y = player.y + player.vel.y
- if love.keyboard.isDown("left") then
- player.vel.x = player.vel.x - 0.2
- elseif love.keyboard.isDown("right") then
- player.vel.x = player.vel.x + 0.2
- elseif player.vel.x > 0 then
- player.vel.x = player.vel.x - 0.1
- elseif player.vel.x < 0 then
- player.vel.x = player.vel.x + 0.1
- end
- if player.vel.x > -0.1 and player.vel.x < 0.1 then
- player.vel.x = 0
- end
- if player.y > 327 then
- player.y = 327
- player.vel.y = 0
- landed = true
- elseif landed == false then
- player.vel.y = player.vel.y + 0.4
- end
- end
- function love.draw()
- if not play and not paused and not win then
- menu.graphic = love.graphics.draw(menu.image,0,-165)
- elseif paused then
- pause.graphic = love.graphics.draw(pause.image,0,-165)
- elseif play then
- love.graphics.draw(background.image,0,0)
- love.graphics.draw(ground.image,0,527)
- love.graphics.draw(player.image,player.x,player.y)
- end
- end
- function love.mousepressed(x,y,button)
- if playbutton and button == "l" then
- playbutton = false
- play = true
- paused = false
- start = true
- elseif paused and button == "l" then
- play = true
- paused = false
- start = true
- end
- end
- function love.keypressed(key)
- if key == "up" and landed == true then
- player.vel.y = -10
- landed = false
- end
- if key == "escape" then
- play = false
- paused = true
- start = true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement