Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---@diagnostic disable: unused-function
- local function wrapPs(peripheralName)
- local periTab={}
- local sideTab={}
- if peripheralName==nil then
- print("Error")
- end
- local peripherals = peripheral.getNames()
- local i2 = 1
- for i =1, #peripherals do
- if peripheral.getType(peripherals[i])==peripheralName then
- periTab[i2]=peripheral.wrap(peripherals[i])
- sideTab[i2]=peripherals[i]
- i2=i2+1
- end
- end
- if periTab~={} then
- return periTab,sideTab
- else
- return nil
- end
- end
- --local mon=wrapPs("monitor")[1]
- --local SX,SY=mon.getSize()
- local cs = {
- colors.red, -- R
- colors.orange, -- O
- colors.yellow, -- Y
- colors.lime, -- G (lime as a bright green)
- colors.green, -- G (darker green)
- colors.lightBlue, -- B (light blue, before deeper blues)
- colors.cyan, -- B (cyan fits between lightBlue and blue)
- colors.blue, -- B (standard blue)
- colors.purple, -- I (indigo)
- colors.magenta, -- V (magenta as a pinkish violet)
- colors.pink, -- extra (soft violet range)
- colors.white, -- neutral (not in rainbow)
- colors.lightGray, -- neutral
- colors.gray, -- neutral
- colors.brown -- extra (not in rainbow)
- }
- local ci=1
- local SX,SY=term.getSize()
- local speed=7
- local dt=1/7
- local posx=math.random(3,SX-3)
- local posy=math.random(3,SY-3)
- local velx=speed*math.cos(0.25*math.pi)
- local vely=speed*math.sin(0.25*math.pi)
- local dimx=1
- local dimy=1
- local function sign(x)
- if x<0 then
- return -1
- else
- return 1
- end
- end
- local LX=false
- local LY=false
- local hits=0
- if not fs.exists("score") then
- local file=fs.open("score","w")
- file.write("0")
- file.close()
- else
- local file=fs.open("score","r")
- local content=file.readAll()
- hits=tonumber(content)
- file.close()
- end
- while true do
- posx=posx+velx*dt
- posy=posy+vely*dt
- local PX=math.floor(posx+0.5)
- local PY=math.floor(posy+0.5)
- local hs=0
- if ((posx+dimx)>SX or posx<1)and LX==false then
- velx=-velx
- LX=true
- hs=hs+1
- elseif not ((posx+dimx)>SX or posx<1) then
- LX=false
- end
- if ((posy+dimy)>SY or posy<1)and LY==false then
- vely=-vely
- LY=true
- hs=hs+1
- elseif not ((posy+dimy)>SY or posy<1) then
- LY=false
- end
- if hs==2 then
- hits=hits+1
- --local naf=math.atan(vely,velx)+math.random(-0.01,0.01)
- --velx=speed*math.cos(naf)
- --vely=speed*math.sin(naf)
- local file=fs.open("score","w")
- file.write(tostring(hits))
- file.close()
- end
- ci=ci+1
- if ci>#cs then
- ci=1
- end
- term.clear()
- paintutils.drawFilledBox(0,0,SX,SY,colours.black)
- paintutils.drawBox(PX, PY,PX+dimx, PY+dimy,cs[ci])
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colours.black)
- term.setTextColour(colours.green)
- term.write("Hits: "..hits)
- sleep(dt)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement