Advertisement
hevohevo

CC: exercise9_1

May 19th, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. -- exercise9_1
  2. -- L字型が下に落ちる
  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 drawLShape(x,y,color)
  18.   drawPoint(x,y,color)
  19.   drawPoint(x,y+1,color)
  20.   drawPoint(x,y+2,color)
  21.   drawPoint(x+1,y+2,color)
  22.   drawPoint(x+2,y+2,color)
  23. end
  24.  
  25. -- Main
  26. for y=1,20 do
  27.   init()  -- 画面を初期化する
  28.   drawLShape(2,y,colors.red)  -- 指定した座標に指定した色で点を描く
  29.   os.sleep(0.5)  -- 0.5秒待つ
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement