nonogamer9

3d

Oct 27th, 2025 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. local mapWidth, mapHeight = 64, 64
  2. local screenW, screenH = term.getSize()
  3. local cam = {x = 32, y = 20, z = 32, angle = 0}
  4. local D = 100
  5.  
  6. local function getMapColor(x, z)
  7. local tile = map[math.floor(z % mapHeight) + 1][math.floor(x % mapWidth) + 1]
  8. return tile -- color code or char
  9. end
  10.  
  11. while true do
  12. for y = screenH // 2, screenH do
  13. local lam = cam.y / (y - screenH/2 + 1)
  14. local cosA, sinA = math.cos(cam.angle), math.sin(cam.angle)
  15. local startX = cam.x - cosA * lam * 60 + sinA * lam * 60
  16. local startZ = cam.z - sinA * lam * 60 - cosA * lam * 60
  17. local stepX = (2 * cosA * lam * 60) / screenW
  18. local stepZ = (2 * sinA * lam * 60) / screenW
  19. term.setCursorPos(1, y)
  20. for x = 1, screenW do
  21. local tile = getMapColor(startX, startZ)
  22. term.write(tile)
  23. startX = startX + stepX
  24. startZ = startZ + stepZ
  25. end
  26. end
  27. sleep(0)
  28. end
  29.  
Advertisement
Add Comment
Please, Sign In to add comment