修复重新制定(LUA)的翘曲

发布于 2025-01-29 00:34:36 字数 1316 浏览 4 评论 0原文

function RENDER_RAY(plr,rayNumber,Ray_Distance,RayAmount,rayAngle)
    local theta = plr.angle - FOV/2
    local diss = Ray_Distance * math.cos(math.rad(theta - plr.angle))

    local screenWidth = love.graphics.getWidth()
    local screenHeight = love.graphics.getHeight()
    local colorDistance = (255 - diss/1.5)/255
    if colorDistance > 0 then
        love.graphics.setColor(colorDistance,colorDistance,colorDistance,1)
    else
        love.graphics.setColor(0,0,0,1)
    end
    local wallHeight = math.Clamp(screenHeight-diss, 0 , 99999999)
    love.graphics.rectangle("fill",(screenWidth/RayAmount) * rayNumber,(screenHeight/2)- 
    allHeight/2,screenWidth/RayAmount,wallHeight)
end

(使用love2d)

这是呈现柱状的功能。 每当施放新的射线时,它都称为该功能,因此该功能一次仅处理1射线。

PLR只是包含玩家(x,y,Angle)的PLR对象 诸如plr.angle和rayangle之类的一切都是标准数学 ray_distance只是距离射线击中XY和XY XY的距离

,您可以看到IV尝试修复翘曲,但它不会消失 IV试图找到一个很好的解决方案,但我能找到的最好的解决方案对翘曲没有影响!

屏幕截图:

“

“

function RENDER_RAY(plr,rayNumber,Ray_Distance,RayAmount,rayAngle)
    local theta = plr.angle - FOV/2
    local diss = Ray_Distance * math.cos(math.rad(theta - plr.angle))

    local screenWidth = love.graphics.getWidth()
    local screenHeight = love.graphics.getHeight()
    local colorDistance = (255 - diss/1.5)/255
    if colorDistance > 0 then
        love.graphics.setColor(colorDistance,colorDistance,colorDistance,1)
    else
        love.graphics.setColor(0,0,0,1)
    end
    local wallHeight = math.Clamp(screenHeight-diss, 0 , 99999999)
    love.graphics.rectangle("fill",(screenWidth/RayAmount) * rayNumber,(screenHeight/2)- 
    allHeight/2,screenWidth/RayAmount,wallHeight)
end

(using love2d)

this is the function that renders the Columbs.
its called every time a new ray is casted, so the function is only dealing with 1 ray at a time.

plr is just the plr object that contains the (x,y,angle) of the player
everything like plr.angle and RayAngle is just the standard math.rad
and ray_distance is just the distance from the ray HIT x y and the player x y

as you can see iv tried fixing the warping but its not going away
Iv tried to find a good solution but the best one i could find has no effect on the warping!

Screenshots:

1

2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文