mirror of
https://github.com/libretro/retroluxury.git
synced 2024-11-23 07:39:47 +00:00
generate/read collision bits
This commit is contained in:
parent
9f86628ac5
commit
3d754904fe
@ -579,29 +579,23 @@ local function compile_cmd( args )
|
||||
end
|
||||
end
|
||||
|
||||
-- collision bits
|
||||
if coll then
|
||||
-- collision bits
|
||||
local bits, bit = 0, 1
|
||||
|
||||
for y = 1, map.height do
|
||||
for x = 1, map.width do
|
||||
local blocked = false
|
||||
|
||||
for i = 1, #coll do
|
||||
for _, layer in ipairs( map.layers ) do
|
||||
if layer.name == coll[ i ] then
|
||||
if layer.tiles[ y ][ x ] then
|
||||
blocked = true
|
||||
if layer.tiles[ y ][ x ] ~= 0 then
|
||||
bits = bits | bit
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if blocked then
|
||||
bits = bits | bit
|
||||
end
|
||||
|
||||
if bit == 0x80000000 then
|
||||
out:writeu32( bits )
|
||||
bits, bit = 0, 1
|
||||
|
16
src/rl_map.c
16
src/rl_map.c
@ -113,6 +113,22 @@ rl_map_t* rl_map_create( const void* data, size_t size, const rl_tileset_t* tile
|
||||
}
|
||||
}
|
||||
|
||||
int numqw = ( width * height + 31 ) / 32;
|
||||
uint32_t* restrict collision = (uint32_t*)rl_malloc( numqw * sizeof( uint32_t ) );
|
||||
|
||||
if ( !collision )
|
||||
{
|
||||
return destroy( map );
|
||||
}
|
||||
|
||||
map->collision = collision;
|
||||
const uint32_t* restrict coll_end = collision + numqw;
|
||||
|
||||
while ( collision < coll_end )
|
||||
{
|
||||
*collision++ = ne32( *ptr.u32++ );
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user