SHARE
TWEET

yellowsquare

a guest Dec 15th, 2013 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("Click the yellow square")
  4. print("Made by mrSLIMEguy")
  5. print("Click the yellow square to score points!")
  6. print("Press Q to quit")
  7. print(" ")
  8. --term.setTextColour(colours.yellow)
  9. print("Press any key to start")
  10.  
  11. event, key = os.pullEvent("key")
  12.  
  13. score = 0
  14.  
  15. term.clear()
  16. term.setCursorPos(1,1)
  17.  
  18. w,h = term.getSize()
  19.  
  20. sx = math.random(1,w)
  21. sy = math.random(1,h)
  22.  
  23. while true do
  24.  term.setCursorPos(1,1)
  25.  print("Score: "..tostring(score))
  26.  if sx and sy == oldsx and oldsy then
  27.  paintutils.drawPixel(sx,sy,colours.red)
  28.  else
  29.  paintutils.drawPixel(sx,sy,colours.yellow)
  30.  end
  31.  
  32.  event, data1, data2, data3 = os.pullEvent()
  33.  
  34.  if event == "key" and data1 == 16 then
  35.   term.clear()
  36.   term.setCursorPos(1,1)
  37.   print("Thanks for playing! You got "..tostring(score).." points!")
  38.   break
  39.  elseif event == "mouse_click" and data1 == 1 then
  40.   if data2 == sx and data3 == sy then
  41.    score = score+1
  42.    oldsx = sx
  43.    oldsy = sy
  44.   else
  45.    term.clear()
  46.    term.setCursorPos(1, 1)
  47.    print("Thanks for playing! You got "..tostring(score).." points!")
  48.   break
  49.   end            
  50.   if score < 0 then
  51.   term.clear()
  52.   term.setCursorPos(1, 1)
  53.   print("Game Over!")
  54.   print("You got negative points!")
  55.   break
  56.   end
  57.    
  58.    sx = math.random(1,w)
  59.    sy = math.random(1,h)
  60.    
  61.  end
  62. end
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