Advertisement
ninja_axiom

ccgametest

Sep 20th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. local monitor = peripheral.wrap("right")
  2. gameEnd = false
  3. local xPos
  4. local yPos
  5. i=0
  6. pod1 = {x=1,y=1}
  7. pod2 = {x=5,y=1}
  8. pod3 = {x=9,y=1}
  9. pod4 = {x=13,y=1}
  10.  
  11. while gameEnd == false do
  12.     local timeout = os.startTimer(.5)
  13.     monitor.setBackgroundColor(colors.red)
  14.     monitor.setCursorPos(pod1.x,pod1.y)
  15.     monitor.write("O")
  16.     monitor.setCursorPos(pod2.x,pod2.y)
  17.     monitor.write("O") 
  18.     monitor.setCursorPos(pod3.x,pod3.y)
  19.     monitor.write("O")
  20.     monitor.setCursorPos(pod4.x,pod4.y)
  21.     monitor.write("O")
  22.  
  23.     eventx = {os.pullEvent()}
  24.     os.sleep(.5)
  25.     --print(eventx[1]) Name
  26.     --print(eventx[3]) XPos
  27.     --print(eventx[4]) YPos
  28.  
  29.     if eventx[1] == "monitor_touch" then
  30.         xPos = eventx[3]
  31.         yPos = eventx[4]
  32.         if ( (xPos == pod1.x) and (yPos == pod1.y)) then
  33.             pod1.y = 1
  34.         end
  35.         if ( (xPos == pod2.x) and (yPos == pod2.y)) then
  36.             pod2.y = 1
  37.         end
  38.         if ( (xPos == pod3.x) and (yPos == pod3.y)) then
  39.             pod3.y = 1
  40.         end
  41.         if ( (xPos == pod4.x) and (yPos == pod4.y)) then
  42.             pod4.y = 1
  43.         end
  44.     end
  45.    
  46.     if eventx[1] == "timer" and eventx[2] == timeout then
  47.         print("going")
  48.     end
  49.    
  50.     monitor.setBackgroundColor(colors.black)
  51.     monitor.clear()
  52.     pod1.y = pod1.y +1
  53.     pod2.y = pod2.y +1
  54.     pod3.y = pod3.y +1
  55.     pod4.y = pod4.y +1
  56.     if pod1.y > 12 then
  57.         pod1.y = 1
  58.     end
  59.     if pod2.y > 12 then
  60.         pod2.y = 1
  61.     end
  62.     if pod3.y > 12 then
  63.         pod3.y = 1
  64.     end
  65.     if pod4.y > 12 then
  66.         pod4.y = 1
  67.     end
  68.  
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement