我转动了一个未在字符串表中删除的2d渲染的映射,例如:

“render= {{ople,50,60,2}}”

图像是图像(我正在使用love2d lua框架) 50是X轴 60是Y轴 2是图像ID(这是实际表中的内容。)

但是,有100个,所有无组织和东西,我需要将它们oragnise or or or in to结构化地图。

这是奇数的比特:当我变成一个有组织的字符串时..有点在逆时针旋转90 *角度。

说我想要的结果

{ 
{7,6,5}, 
{6,5,4}, 
} 
.

我会得到:

{ 
{5,4}, 
{6,5}, 
{7,6}, 
} 
.

显然没有错误,因为它在技术上工作时,错误地旋转。这是相关代码:

function OrganiseRenderIntoMap() 
    MapString = "" 

    Map2 = {} 
    MaxSoFarX = 0 
    MaxSoFarY = 0 
    for _,v in pairs(Render) do 
        if v[2] > MaxSoFarX then 
            MaxSoFarX = v[2] 
        elseif v[3] > MaxSoFarY then 
            MaxSoFarY = v[3] 
        end 
    end 

    for currx = 0, MaxSoFarX, 32 do 
        Map2[currx] = {} 
        MapString = MapString.."{" 
        for curry = 0, MaxSoFarY, 32 do 
            MapString = MapString..GetRenderPos(currx,curry).."," 
            Map2[currx][curry] = GetRenderPos(currx,curry) 
        end 
        MapString = MapString.."},\n" 
    end 

    return MapString 
end 


function GetRenderPos(locx,locy) 
    for _,v in pairs(Render) do 
        if v[2] == locx and v[3] == locy then 
            return v[4] 
        end 
    end 
end 
.

有帮助吗?

解决方案

看看我的löve瓷砖教程。第 1d-strings 说如何处理“切换x”和y“问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top