Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.redirect(peripheral.wrap("top"))
- term.setBackgroundColor(colors.black)
- term.clear()
- local w,h = term.getSize()
- local score1 = 0
- local score2 = 0
- local ballx = w/2
- local bally = h/2
- local ballvx = -1
- local ballvy = 1
- function draw()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setBackgroundColor(colors.green)
- term.setCursorPos(ballx, bally)
- term.write(" ")
- term.setTextColor(colors.green)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(2, 1)
- term.write(score1)
- term.setCursorPos(w-1, 1)
- term.write(score2)
- end
- function moveball()
- while true do
- sleep(0.1)
- ballx = ballx + ballvx
- bally = bally + ballvy
- if bally > h-1 then
- ballvy = -ballvy
- end
- if bally < 1 then
- ballvy = -ballvy
- end
- if ballx > 2 and ballx < 3 then
- ballvx = -ballvx
- end
- if ballx > w-1 and ballx < w then
- ballvx = -ballvx
- end
- if ballx > w then
- score1 = score1+1
- ballx = w/2
- bally = h/2
- ballvx = -1
- ballvy = 1
- end
- if ballx < 1 then
- score2 = score2+1
- ballx = w/2
- bally = h/2
- ballvx = 1
- ballvy = 1
- end
- draw()
- end
- end
- moveball()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement