NightFox’s Lib
|
Collision maps only have map information, so the collisions have a granularity of 8x8 pixels. More...
Data Structures | |
struct | NF_TYPE_CMAP_INFO |
Struct that holds collision map information. More... | |
Macros | |
#define | NF_SLOTS_CMAP 32 |
Maximum number of available collision maps. | |
Functions | |
void | NF_InitCmapBuffers (void) |
Initialize buffers to store collision map data. More... | |
void | NF_ResetCmapBuffers (void) |
Reset collision map buffers, clearing all data in RAM. More... | |
void | NF_LoadCollisionMap (const char *file, u32 id, u32 width, u32 height) |
Load a collision map into RAM in the specified slot. More... | |
void | NF_UnloadCollisionMap (u32 id) |
Unload from RAM the collision map at the specified slot. More... | |
u32 | NF_GetTile (u32 slot, s32 x, s32 y) |
Return the tile number at the specified position. More... | |
void | NF_SetTile (u32 slot, s32 x, s32 y, u32 value) |
Set the value of the tile of a collision map at the specified position. More... | |
void | NF_LoadCollisionBg (const char *file, u32 id, u32 width, u32 height) |
Load a collision background to RAM at the specified slot. More... | |
void | NF_UnloadCollisionBg (u32 id) |
Unload from RAM the collision background at the specified slot. More... | |
u8 | NF_GetPoint (u32 slot, s32 x, s32 y) |
Returns the color number at the specified coordinates. More... | |
Variables | |
NF_TYPE_CMAP_INFO | NF_CMAP [NF_SLOTS_CMAP] |
Information of all collision maps. | |
Collision maps only have map information, so the collisions have a granularity of 8x8 pixels.
This is useful for games where the map is simple and it doesn't have many details that affect collisions.
Collision backgrounds also have tile information, so they can have information at a pixel granularity.
u8 NF_GetPoint | ( | u32 | slot, |
s32 | x, | ||
s32 | y | ||
) |
Returns the color number at the specified coordinates.
If the coordinates are outside of the background, it returns 0.
slot | Slot number (0 - 31) |
x | X coordinate in pixels. |
y | Y coordinate in pixels. |
u32 NF_GetTile | ( | u32 | slot, |
s32 | x, | ||
s32 | y | ||
) |
Return the tile number at the specified position.
You must place your tileset in the first row of the collision map image.
slot | Slot number (0 - 31) |
x | X coordinate in pixels. |
y | Y coordinate in pixels. |
void NF_InitCmapBuffers | ( | void | ) |
Initialize buffers to store collision map data.
You must call this function once in you code before loading any collision map.
void NF_LoadCollisionBg | ( | const char * | file, |
u32 | id, | ||
u32 | width, | ||
u32 | height | ||
) |
Load a collision background to RAM at the specified slot.
You must specify the width and height of the background in pixels. Remember to make your colision background 8 pixels taller than your real background and to use this first row of tiles to define your color tileset for the collision background.
Use the "Convert_CMaps.bat" script in the GRIT folder to convert you maps. You need to copy the ".cmp" and ".dat" files to your game data folder.
file | File name |
id | Slot number (0 - 31) |
width | Map width (in pixels) |
height | Map height (in pixels) |
void NF_LoadCollisionMap | ( | const char * | file, |
u32 | id, | ||
u32 | width, | ||
u32 | height | ||
) |
Load a collision map into RAM in the specified slot.
You must specify the width and height of the map in pixels. Remember to make your collision map 8 pixels taller than your background and to use this first row of tiles to define your tileset for the collision map.
Use the "Convert_CMaps.bat" script in the GRIT folder to convert your maps. You need to copy the ".cmp" file to your game data folder.
file | File name |
id | Slot number (0 - 31) |
width | Map width (in pixels) |
height | Map height (in pixels) |
void NF_ResetCmapBuffers | ( | void | ) |
Reset collision map buffers, clearing all data in RAM.
It's useful to use this function during game level changes, for example, to easily clear all data before loading the new level.
void NF_SetTile | ( | u32 | slot, |
s32 | x, | ||
s32 | y, | ||
u32 | value | ||
) |
Set the value of the tile of a collision map at the specified position.
slot | Slot number (0 - 31) |
x | X coordinate in pixels. |
y | Y coordinate in pixels. |
value | New tile. |
void NF_UnloadCollisionBg | ( | u32 | id | ) |
Unload from RAM the collision background at the specified slot.
id | Slot number (0 - 31) |
void NF_UnloadCollisionMap | ( | u32 | id | ) |
Unload from RAM the collision map at the specified slot.
id | Slot number (0 - 31) |