Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- exercise9_2
- -- L字型を上下に動かす
- -- Functions
- function init()
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- end
- function drawPoint(x,y,color)
- term.setBackgroundColor(color)
- term.setCursorPos(x,y)
- term.write(" ")
- end
- function drawLShape(x,y,color)
- drawPoint(x,y,color)
- drawPoint(x,y+1,color)
- drawPoint(x,y+2,color)
- drawPoint(x+1,y+2,color)
- drawPoint(x+2,y+2,color)
- end
- -- Main
- local y = 1
- while true do
- init() -- 画面を初期化する
- drawLShape(2, y, colors.red) -- 指定した座標に指定した色で点を描く
- local event, moji = os.pullEvent("char")
- if moji == "z" then
- y = y + 1
- else
- y = y - 1
- end
- os.sleep(0.3) -- 0.5秒待つ
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement