Advertisement
MrLetsplay2003

Game "Jump IT" (LUA/Computercraft)

May 1st, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. --Here is a new Program(Game) for Computercraft, hope you enjoy :D
  2. --You also have to download the menu for this game: pastebin.com/nYmuKMn1
  3. --INFORMATION: the "title.img" will be added soon
  4. --if you find any fails or bugs please contact me i will update it regular
  5. --You have to install the game with the INSTALLER!!!
  6. --!!!INSTALLER for the game: --> pastebin.com/hPg7L2QY !!!
  7.  
  8. shell.run("clear")
  9. write("Your Name: ")
  10. name= io.read()
  11. fs.makeDir("score")
  12. a=1
  13. shell.run("clear")
  14. print("This game was created for 26x20 advanced pocket computer")
  15. sleep(5)
  16. shell.run("clear")
  17. t=paintutils.loadImage("title.img")
  18. paintutils.drawImage(t,1,1)
  19. term.setBackgroundColor(32768)
  20. sleep(3)
  21. shell.run("clear")
  22. score = 0
  23. while true do
  24.  pos = math.random(1,20)
  25.  function printState()
  26.  shell.run("clear")
  27.  Floor()
  28.  term.setCursorPos(1,1)
  29.  print("Score:"..score)
  30.  term.setCursorPos(pos,10)
  31.  term.setBackgroundColor(256)
  32.  print(" ")
  33.  term.setBackgroundColor(32768)
  34.  end
  35.  function Floor()
  36.  while a < 30 do
  37.  term.setBackgroundColor(4096)
  38.  term.setCursorPos(a,11)
  39.  a=a+1
  40.  print(" ")
  41.  end
  42.  a=1
  43.  term.setBackgroundColor(32768)
  44.  end
  45.  printState()
  46.  sleep(3)
  47.  shell.run("clear")
  48.  print("Score:"..score)
  49.  term.setCursorPos(pos,10)
  50.  term.setBackgroundColor(256)
  51.  print(" ")
  52.  term.setBackgroundColor(32768)
  53.  term.setCursorPos(1,12)
  54.  write("How many pixels is the line away??? ")
  55.  Floor()
  56.  term.setCursorPos(14,13)
  57.  weit=io.read()
  58.  shell.run("clear")
  59.  Floor()
  60.  term.setCursorPos(pos,10)
  61.  term.setBackgroundColor(256)
  62.  print(" ")
  63.  term.setBackgroundColor(32768)
  64.  term.setCursorPos(weit-6,10)
  65.  print("@")
  66.  printState()
  67.  Floor()
  68.  term.setCursorPos(weit-5,10)
  69.  print("@")
  70.  sleep(0.3)
  71.  printState()
  72.  Floor()
  73.  term.setCursorPos(weit-4,10)
  74.  print("@")
  75.  sleep(0.3)
  76.  printState()
  77.  Floor()
  78.  term.setCursorPos(weit-3,10)
  79.  print("@")
  80.  sleep(0.3)
  81.  printState()
  82.  Floor()
  83.  term.setCursorPos(weit-2,10)
  84.  print("@")
  85.  sleep(0.3)
  86.  printState()
  87.  term.setCursorPos(weit-1,10)
  88.  print("@")
  89.  sleep(0.5)
  90.  printState()
  91.  term.setCursorPos(weit,9)
  92.  print("@")
  93.  sleep(0.5)
  94.  printState()
  95.  term.setCursorPos(weit+1,10)
  96.  print("@")
  97.  term.setCursorPos(1,11)
  98.  if weit+0 == pos then
  99.   term.setCursorPos(1,12)
  100.   print("Good")
  101.   sleep(1)
  102.   score = score+1
  103.   shell.run("clear")
  104.  else
  105.     term.setCursorPos(1,12)
  106.     print("Fail, it was "..pos.." Pixels")
  107.     sleep(1)
  108.     print("YOU LOST")
  109.     if fs.exists("score/"..name) then
  110.     list=fs.open("score/"..name,"r")
  111.     firstScore=list.readLine()    
  112.     list.close()
  113.     if firstScore+0 < score+0 then
  114.      list = fs.open("score/"..name,"w")
  115.      list.writeLine(score)
  116.      list.close()
  117.     end
  118.     sleep(2)
  119.     shell.run("clear")
  120.     shell.run("JumpMenu")
  121.     break
  122.     else
  123.     newlist=fs.open("score/"..name,"w")
  124.     newlist.writeLine(score)
  125.     newlist.close()
  126.     sleep(1)
  127.     shell.run("clear")
  128.     shell.run("JumpMenu")
  129.     break
  130.    end
  131.   end
  132.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement