SHARE
TWEET

CC: pocket4

hevohevo Apr 25th, 2016 (edited) 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pocket4
  2. -- 四角形が縦に動く
  3.  
  4. -- Functions
  5. function init()
  6.   term.setTextColor(colors.white)
  7.   term.setBackgroundColor(colors.black)
  8.   term.clear()
  9. end
  10.  
  11. function drawPoint(x,y,color)
  12.   term.setBackgroundColor(color)
  13.   term.setCursorPos(x,y)
  14.   term.write(" ")
  15. end
  16.  
  17. function drawSquare(x,y,color)
  18.   drawPoint(x,y,color)
  19.   drawPoint(x+1,y,color)
  20.   drawPoint(x, y+1, color)
  21.   drawPoint(x+1, y+1, color)
  22. end
  23.  
  24. -- Main
  25. for y=1,20 do
  26.   init()  -- 画面を初期化する
  27.   drawSquare(2,y,colors.red)  -- 指定した座標に指定した色で点を描く
  28.   os.sleep(0.5)  -- 0.5秒待つ
  29. end
RAW Paste Data
Top