Advertisement
nitrogenfingers

Untitled

Feb 22nd, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. local lpath = shell.resolve(".").."/"
  2. os.loadAPI(lpath.."gameutils")
  3.  
  4. --[[ Section: Asset Initialization ]]--
  5.  
  6. local player = gameutils.loadSprite(lpath.."protag.nfp", 6, 5)
  7. local bg = gameutils.loadSprite(lpath.."level.nfp", 1, 1)
  8.  
  9. local refreshRate = 0.25
  10. local gtID = os.startTimer(refreshRate)
  11.  
  12. local ypropulsion = 1
  13. local onGround = false
  14. local jumpHeight = 2
  15.  
  16. local running = true
  17. local deathByLava = false
  18.  
  19. gameutils.initializeBuffer()
  20.  
  21. --[[ Section: Drawing and Interface ]]--
  22.  
  23. function drawGame()
  24. gameutils.clearBuffer(colours.black)
  25. gameutils.writeToBuffer(bg)
  26. gameutils.writeToBuffer(player)
  27. gameutils.drawBuffer()
  28. end
  29.  
  30. function handleInput()
  31. local id, p1 = os.pullEvent()
  32.  
  33. local px, py = player:getPos()
  34.  
  35. if id == "key" then
  36.  
  37. elseif id == "timer" and p1 == gtID then
  38.  
  39. gtID = os.startTimer(refreshRate)
  40. end
  41. end
  42.  
  43. while running do
  44. drawGame()
  45. handleInput()
  46. end
  47.  
  48. term.setBackgroundColour(colours.black)
  49. shell.run("clear")
  50. sleep(0.1)
  51.  
  52. if deathByLava then
  53. term.setTextColour(colours.red)
  54. print("You fell in lava!")
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement