Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mapWidth, mapHeight = 64, 64
- local screenW, screenH = term.getSize()
- local cam = {x = 32, y = 20, z = 32, angle = 0}
- local D = 100
- local function getMapColor(x, z)
- local tile = map[math.floor(z % mapHeight) + 1][math.floor(x % mapWidth) + 1]
- return tile -- color code or char
- end
- while true do
- for y = screenH // 2, screenH do
- local lam = cam.y / (y - screenH/2 + 1)
- local cosA, sinA = math.cos(cam.angle), math.sin(cam.angle)
- local startX = cam.x - cosA * lam * 60 + sinA * lam * 60
- local startZ = cam.z - sinA * lam * 60 - cosA * lam * 60
- local stepX = (2 * cosA * lam * 60) / screenW
- local stepZ = (2 * sinA * lam * 60) / screenW
- term.setCursorPos(1, y)
- for x = 1, screenW do
- local tile = getMapColor(startX, startZ)
- term.write(tile)
- startX = startX + stepX
- startZ = startZ + stepZ
- end
- end
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment