Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- shell.run("clr")
- local bloons = {}
- fs.open("poidata",'w')
- function createBloon(xpos,ypos,col,dir)
- local bloon = {}
- bloon.color = col
- bloon.xpos = xpos
- bloon.ypos = ypos
- bloon.xprev = 1
- bloon.yprev = 1
- bloon.dir = dir
- return bloon
- end
- function rand(...)
- local tArgs = {...}
- local decision = math.random(1,#tArgs)
- return tArgs[decision]
- end
- function log(words)
- local h = fs.open("poidata",'a')
- h.writeLine(words)
- h.close()
- end
- --[[ bloons.red = createBloon(w,5,colors.red)
- bloons.blue = createBloon(1,3,colors.blue)
- bloons.green = createBloon(w,7,colors.green)
- bloons.pink = createBloon(1,9,colors.pink)
- bloons.lead = createBloon(1,11,colors.grey)
- bloons.yellow = createBloon(w,13,colors.yellow)
- bloons.ceramic = createBloon(w,15,colors.brown)
- bloons.camo = createBloon(1,17,colors.lime)]]
- for i = 1, w, 2 do
- bloons[i] = createBloon(math.random(1,w),i,2^math.random(1,15),rand("right","left"))
- end
- function events()
- while true do
- local e = {os.pullEvent("mouse_click")}
- log(textutils.serialize(e))
- for i,v in pairs(bloons) do
- if e[3] == v.xpos or e[3] == v.xprev then
- log("x match")
- if e[4] == v.ypos or e[4] == v.yprev then
- log("hit")
- v.color = v.color/2
- log(bloons[i].color)
- log("^ bloons[i].color")
- log(v.color/2)
- end
- end
- end
- end
- end
- function ai()
- while true do
- for i,v in pairs(bloons) do
- paintutils.drawPixel(v.xpos,v.ypos,v.color)
- paintutils.drawPixel(v.xprev,v.yprev,colors.black)
- v.xprev,v.yprev = v.xpos,v.ypos
- if v.xpos == 1 then
- v.dir = "right"
- elseif v.xpos == w then
- v.dir = "left"
- end
- if v.dir == "right" then
- v.xpos = v.xpos + 1
- elseif v.dir == "left" then
- v.xpos = v.xpos - 1
- end
- end
- sleep(.05)
- end
- end
- while true do
- parallel.waitForAny(events,ai)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement