Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stage
- local groundlvl=-200
- function love.load(arg)
- if arg[#arg] == "-debug" then require("mobdebug").start() end
- themeA = love.audio.newSource( "themeA.ogg", "stream")
- themeA:setVolume(0.5)
- perehodSnd=love.audio.newSource("sounds/perehod.ogg","stream")
- love.audio.play(themeA)
- logoImg=love.graphics.newImage("graphics/logo.png")
- stage=0
- player = {
- x = 0,
- y = groundlvl,
- image = love.graphics.newImage("graphics/plr.png"),
- y_velocity = 0,
- }
- gravity = 600
- jump_height = 300
- winW, winH = love.graphics.getWidth(), love.graphics.getHeight()
- end
- function love.draw()
- if stage==0 then
- love.graphics.draw(logoImg, 0,0)
- love.graphics.print("PRESS ENTER TO PLAY!!!!!!!!", 10, 500)
- love.graphics.print("Ruslan isaev (c)2015",500,550)
- elseif stage==1 then
- love.graphics.draw(player.image,player.x,-player.y)
- love.graphics.rectangle("fill", 0, winH / 2, winW, winH / 2)-- рисуем землю, используя наши перемнные minW и minH рисуем ее посредине экрана
- love.graphics.translate(winW / 2, winH / 2) -- вам это лучше не знать :]
- end
- end
- function love.keypressed(key)
- if stage==0 then
- if key=="return" then
- stage=stage+1
- end
- elseif stage==1 then
- if key == "w" then
- if player.y_velocity == 0 then -- мы пробуем узнать, на земле ли герой, если да - прыгаем
- player.y_velocity = jump_height
- end
- end
- end
- if key=="escape" then
- exit(1);
- end
- end
- function love.update(dt)
- if love.keyboard.isDown("a") then
- player.x = player.x - 150*dt
- end
- if love.keyboard.isDown("d") then
- player.x = player.x + 150*dt
- end
- --тут движение, это мы знаем
- if player.y_velocity ~= 0 then -- если мы прыгаем
- player.y = player.y + player.y_velocity * dt
- -- изменяем y нашего персонажа
- player.y_velocity = player.y_velocity - gravity * dt
- if player.y < groundlvl then -- мы опять на земле
- player.y_velocity = 0 -- сила равна 0
- player.y = groundlvl -- у = 0
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement