Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- neuralInt = peripheral.wrap("back")
- modem = peripheral.wrap("top")
- modem.open(1)
- c = neuralInt.canvas()
- c.clear()
- window = {}
- window[1],window[2] = c.getSize()
- roc = {}
- owner = neuralInt.getMetaOwner()
- gpsx,gpsy,gpsz = gps.locate()
- if gpsx == nil or gpsy == nil or gpsz == nil then
- error("GPS not located")
- end
- block = 32
- scale = 2
- initx = math.floor(gpsz*block/scale)
- inity = math.floor(gpsx*block/scale)
- world = {
- {1,1,1,1,1,1,1,1,1},
- {1,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,1},
- {1,0,2,0,3,0,4,0,1},
- {1,0,0,0,0,0,0,0,1},
- {1,1,1,1,1,1,1,1,1}
- }
- cam = {160,160,180}
- fov = 70
- lines = {}
- lineThickness = math.floor(window[1]/(fov))+1
- renderdist = 1000
- gen = true
- colors = {
- {255,255,255},
- {255,0,0},
- {0,255,0},
- {0,0,255},
- {255,255,0},
- }
- for i = 1, 360 do
- x = math.cos(math.rad(i))*-1
- y = math.sin(math.rad(i))
- table.insert(roc,{x,y})
- end
- function setUpLines()
- for l = 0,fov do
- table.insert(lines,c.addRectangle(l*lineThickness,0,lineThickness,50,255))
- end
- end
- function trig(degrees)
- degr = math.floor(degrees)
- while degr > 360 do
- degr = degr - 360
- end
- while degr < 1 do
- degr = degr + 360
- end
- return roc[degr]
- end
- function Engine()
- detail = 2
- line = math.floor(renderdist/detail/2)
- thickness = math.floor(window[1]/fov)+1
- dist = {}
- color = {}
- for i = 1, fov do
- table.insert(dist,500)
- table.insert(color,{0,0,0})
- end
- for f = 1, fov do
- ff = f
- cx = cam[1]
- cy = cam[2]
- cdeg = cam[3]
- f = f - math.floor(fov/2) - cdeg
- while ff > 359 do
- ff = ff - 360
- end
- while ff < 0 do
- ff = ff + 360
- end
- x = trig(f)[1]
- y = trig(f)[2]
- x = x * detail
- y = y * detail
- for l = 1 ,line do
- l = l *detail
- cx= cx + x
- cy= cy + y
- px = math.floor(cx/block)
- py = math.floor(cy/block)
- if py > #world or py < 1 or px > #world[1] or px < 1 then
- x = x
- else
- if world[py][px] ~= 0 then
- dist[ff] = math.floor(l)
- color[ff] = colors[world[py][px]]
- break
- end
- end
- end
- end
- move = 0
- for a = 1 ,fov do
- i = dist[a]
- i = window[1]/(i+1)*16
- r = color[a][1]
- g = color[a][2]
- b = color[a][3]
- if true then
- lineWidth,lineHeight = lines[a].getSize()
- lines[a].setSize(lineWidth,i)
- lineHeight = i
- linex,liney = lines[a].getPosition()
- liney = math.floor(window[2]/2-(owner.pitch/90)*window[2])-math.floor(lineHeight/2)
- lines[a].setColor(r,g,b)
- lines[a].setPosition(linex,liney)
- end
- move = move + thickness
- end
- end
- f = c.addRectangle(0,0,window[1],window[2])
- f.setColor(0,255,255)
- setUpLines()
- print("press E to exit")
- while true do
- event = os.startTimer(.01)
- out, key = os.pullEvent()
- if out == "key" and key == 18 then
- c.clear()
- break
- end
- Engine()
- owner = neuralInt.getMetaOwner()
- gpsx,gpsy,gpsz = gps.locate()
- if gpsx == nil or gpsy == nil or gpsz == nil then
- c.clear()
- error("GPS not located")
- end
- cam[1] = math.floor(gpsz*block/scale)-initx+80
- cam[2] = math.floor(gpsx*block/scale)-inity+80
- cam[3] = 360-owner.yaw+180
- end
Add Comment
Please, Sign In to add comment