Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The Irritating Game, By Symmetryc
- -- Change the variables to your liking.
- local screen = {}
- local c = {}
- c.back = colors.yellow
- c.b = colors.lightBlue
- local b = {}
- b[1] = {x=math.random(3, 49),y=5,vx=1,vy=-1,h=1,h2=9}
- b[2] = {x=math.random(3, 49),y=15,vx=-1, vy=-1,h=11,h2=18}
- b[3] = {x=25,y=10,w=5}
- b[4] = {x=25,y=19,w=5}
- local speed = 0.6
- local intspeed = 0.9
- local fps = 0.6
- local key = {"j","k","d","f"}
- local count = 0
- local reset = function()
- for i=0, 51 do
- screen[i] = {}
- for i2=1, 19 do
- screen[i][i2] = false
- end
- end
- end
- local draw = function()
- reset()
- for i=1, 2 do
- screen[b[i].x][b[i].y] = i
- end
- for i=3, 4 do
- for i2=b[i].x-((b[i].w-1)/2), b[i].x+((b[i].w-1)/2) do
- screen[i2][b[i].y] = i
- end
- end
- for i=1, 51 do
- for i2=1, 19 do
- term.setCursorPos(i, i2)
- term.setBackgroundColor(screen[i][i2] and c.b or c.back)
- write(" ")
- end
- end
- end
- local time = os.clock()
- local main = function()
- local id = os.startTimer(speed)
- os.startTimer(fps)
- while true do
- draw()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(c.back)
- term.setTextColor(colors.red)
- write(os.clock()-time)
- local e = {os.pullEvent()}
- if e[1]=="char" then
- local n = (e[2]==key[1] or e[2]==key[2]) and 3 or 4
- local d = ((e[2]==key[1] or e[2]==key[3]) and -1) or ((e[2]==key[2] or e[2]==key[4]) and 1) or 0
- b[n].x = ((b[n].x+d)>=3 and (b[n].x+d)<=49) and b[n].x+d or b[n].x
- elseif e[1]=="timer" and e[2]==id then
- count = count+1
- if count>5 then
- speed = speed*intspeed
- count = 0
- end
- for i=1, 2 do
- if (b[i].x+b[i].vx)>51 or (b[i].x+b[i].vx)<1 then
- b[i].vx = -b[i].vx
- end
- if (b[i].y+b[i].vy)>b[i].h2 and ((b[i+2].x-(b[i+2].w-1)/2)>b[i].x or (b[i+2].x+(b[i+2].w-1)/2)<b[i].x) then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- error("Your score was: "..(os.clock()-time), 0)
- elseif (b[i].y+b[i].vy)<b[i].h or (b[i].y+b[i].vy)>b[i].h2 then
- b[i].vy = -b[i].vy
- end
- b[i].x = b[i].vx+b[i].x
- b[i].y = b[i].vy+b[i].y
- end
- id = os.startTimer(speed)
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement