daily pastebin goal
61%
SHARE
TWEET

game.lua

a guest Mar 18th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. modules = peripheral.wrap("back")
  2. canvas = modules.canvas3d()
  3. canvas.clear()
  4. canvas2 = canvas.create()
  5. player = canvas2.addBox(7.8,0,0)
  6. player.setColor(0x00FFFF)
  7. player.setAlpha(100)
  8. for t = -5, 5 do
  9.     t = t - 0.5
  10.     canvas2.addBox(7.8,-1,t)
  11. end
  12. px = 7.8
  13. py = 0
  14. pz = -0.5
  15. function display()
  16.     while true do
  17.         sleep()
  18.         canvas2.recenter()
  19.         player.setPosition(px,py,pz)
  20.     end
  21. end
  22. function control()
  23.     while true do
  24.         _, k = os.pullEvent("key")
  25.         if k == 54 then
  26.             tempp = 1
  27.             count = 0
  28.             repeat
  29.                 count = count + 1
  30.                 tempp = tempp / 1.2
  31.                 py = tempp + py
  32.                 sleep()
  33.             until count == 10
  34.             count = 0
  35.             repeat
  36.                 count = count + 1
  37.                 tempp = tempp * 1.2
  38.                 py = py - tempp
  39.                 sleep()
  40.             until count == 9
  41.             py = 0
  42.         end
  43.         k = nil
  44.     end
  45. end
  46. function enemysp()
  47.     while true do
  48.         enemy = canvas2.addBox(7.8,0,4.5)
  49.         enemy.setColor(0xFFFFFF)
  50.         enemy.setAlpha(130)
  51.         sleep(0.5)
  52.         epos = 4.5
  53.         repeat
  54.             enemy.setPosition(7.8,0,epos)
  55.             epos = epos - 0.5
  56.             sleep(0.1)
  57.             if epos > 0 and epos < 1 then
  58.                 if py == 0 then
  59.                     gameend = true
  60.                 end
  61.             end
  62.         until epos == -6.5
  63.         enemy.remove()
  64.     end
  65. end
  66. function endc()
  67.     repeat
  68.         sleep()
  69.     until gameend == true
  70. end
  71. parallel.waitForAny(endc,display,control,enemysp)
  72. sleep(1)
  73. canvas.clear()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top