Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- local previous = {0,math.floor(h/2)}
- local entry = {1,math.floor(h/2)}
- local exit = {w,math.floor(h/2)}
- local buffer = {}
- for x = 1,w do
- buffer[x] = {}
- for y = 1,h do
- buffer[x][y] = nil
- end
- end
- for x= 1, w do
- buffer[x][math.floor(h/2)] = {char=" ",track=true,backcol=colors.orange}
- end
- function Balloon(layer, delay)
- local balloon = {}
- balloon.speed = layer
- balloon.layer = layer
- balloon.delay = delay
- balloon.pos = entry
- balloon.previous = previous
- balloon.dir = "east"
- if layer == 1 then
- balloon.color = colors.red
- elseif layer == 2 then
- balloon.color = colors.blue
- elseif layer == 3 then
- balloon.color = colors.green
- end
- return balloon
- end
- bloons = {
- red = Balloon(1,0),
- red2 = Balloon(1,2),
- blue = Balloon(2,4),
- green = Balloon(3,7),
- }
- ntime = 0
- for x=1,w do
- for y=1,h do
- if buffer[x][y] then
- term.setBackgroundColor(buffer[x][y].backcol)
- term.setCursorPos(x,y)
- term.write(buffer[x][y].char)
- end
- end
- end
- while true do
- for _,bloon in pairs(bloons) do
- if ntime >= bloon.delay then
- term.setCursorPos(bloon.pos[1],bloon.pos[2])
- term.setBackgroundColor(bloon.color)
- term.write(" ")
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(bloon.previous[1],bloon.previous[2])
- term.write(" ")
- bloon.previous[1],bloon.previous[2] = bloon.pos[1],bloon.pos[2]
- if bloon.dir == "east" then
- bloon.pos[1] = bloon.pos[1] + 1
- end
- end
- end
- sleep(1)
- ntime = ntime + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement