Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lpath = shell.resolve(".").."/"
- os.loadAPI(lpath.."gameutils")
- --[[ Section: Asset Initialization ]]--
- local player = gameutils.loadSprite(lpath.."protag.nfp", 6, 5)
- local bg = gameutils.loadSprite(lpath.."level.nfp", 1, 1)
- local refreshRate = 0.25
- local gtID = os.startTimer(refreshRate)
- local ypropulsion = 1
- local onGround = false
- local jumpHeight = 2
- local running = true
- local deathByLava = false
- gameutils.initializeBuffer()
- --[[ Section: Drawing and Interface ]]--
- function drawGame()
- gameutils.clearBuffer(colours.black)
- gameutils.writeToBuffer(bg)
- gameutils.writeToBuffer(player)
- gameutils.drawBuffer()
- end
- function handleInput()
- local id, p1 = os.pullEvent()
- local px, py = player:getPos()
- if id == "key" then
- elseif id == "timer" and p1 == gtID then
- gtID = os.startTimer(refreshRate)
- end
- end
- while running do
- drawGame()
- handleInput()
- end
- term.setBackgroundColour(colours.black)
- shell.run("clear")
- sleep(0.1)
- if deathByLava then
- term.setTextColour(colours.red)
- print("You fell in lava!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement