Advertisement
Guest User

ballBounce

a guest
Sep 6th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. local LR,UD = 0,0
  2. while true do
  3.   X, Y = term.getCursorPos()
  4.   local function drawBall(x,y)
  5.     term.setCursorPos(x,y)
  6.     print("O")
  7.   end
  8.   if X == 1 then
  9.     LR = 1
  10.   elseif X == 51 then
  11.     LR = 0
  12.   end
  13.   if Y == 1 then
  14.     UD = 0
  15.   elseif Y == 19 then
  16.     UD = 1
  17.   end
  18.   if LR == 1 then
  19.     xpos = X + 1
  20.   elseif LR == 0 then
  21.     xpos = X - 1
  22.   end
  23.   if UD == 1 then
  24.     ypos = Y + 1
  25.   elseif UD == 0 then
  26.     ypos = Y - 1
  27.   end
  28.   drawBall(xpos,ypos)
  29.   sleep(0)
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement