修复重新制定(LUA)的翘曲
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:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论