PVSnesLib
4.3.0
Documentation to code in C or ASM for the Nintendo SNES
|
snes object engine functionality. More...
#include <snes/snestypes.h>
Go to the source code of this file.
Data Structures | |
struct | t_objs |
object definition (64 bytes) More... | |
Macros | |
#define | ACT_BURN 0x0020 |
Action type BURN for object. | |
#define | ACT_CLIMB 0x0008 |
Action type CLIMB for object. | |
#define | ACT_DIE 0x0010 |
Action type DIE for object. | |
#define | ACT_FALL 0x0004 |
Action type FALL for object. | |
#define | ACT_JUMP 0x0002 |
Action type JUMP for object. | |
#define | ACT_STAND 0x0000 |
Action type STAND for object. | |
#define | ACT_WALK 0x0001 |
Action type WALK for object. | |
#define | OB_MAX 64 |
#define | OB_TYPE_MAX 64 |
#define | T_EMPTY 0x0000 |
Type Empty (action will be fall) for tile | |
#define | T_FIRES 0x0002 |
Type Fire (action will be burn) for tile | |
#define | T_LADDER 0x0001 |
Type Ladder (action will be climb) for tile | |
#define | T_PLATE 0x0008 |
Type Plate (action will be jump through and land) for tile | |
#define | T_SLOPED1 0x0021 |
Type Slope 1x1 Down ◣ (action will be descend on it) for tile. | |
#define | T_SLOPELD2 0x0023 |
Type Slope 2x1 lower half Down ◣ (action will be descend on it) for tile. | |
#define | T_SLOPELU2 0x0022 |
Type Slope 2x1 lower half Up ◢ (action will be climb on it) for tile. | |
#define | T_SLOPEU1 0x0020 |
Type Slope 1x1 Up ◢ (action will be climb on it) for tile | |
#define | T_SLOPEUD2 0x0025 |
Type Slope 2x1 upper half Down ◣ (action will be descend on it) for tile | |
#define | T_SLOPEUU2 0x0024 |
Type Slope 2x1 upper half Up ◢ (action will be climb on it) for tile. | |
#define | T_SOLID 0xFF00 |
Type Solid (action is walk only) for tile | |
#define | T_SPIKE 0x0004 |
Type Spike (action will be die) for tile | |
Functions | |
void | objCollidMap (u16 objhandle) |
check if an object collides the map More... | |
void | objCollidMap1D (u16 objhandle) |
check if an object collides the map More... | |
void | objCollidMapWithSlopes (u16 objhandle) |
check if an object collides the map with map slopes management More... | |
u16 | objCollidObj (u16 objhandle1, u16 objhandle2) |
check if two objects are colliding More... | |
void | objGetPointer (u16 objhandle) |
get the pointer to an object from its handle (need to do -1 to have offset after), objptr will has the pointer of the object More... | |
void | objInitEngine (void) |
Initialize object engine, need to be called once. | |
void | objInitFunctions (u8 objtype, void *initfct, void *updfct, void *reffct) |
Initialize the object type functions (initialize, update) More... | |
void | objKill (u16 objhandle) |
kill an object from the game More... | |
void | objKillAll (void) |
kill all objects currently active | |
void | objLoadObjects (u8 *sourceO) |
Load all objects for a specific table in memory. More... | |
u16 | objNew (u8 objtype, u16 x, u16 y) |
Initialize a new object in game, objgetid will has the id of the object. More... | |
void | objRefreshAll (void) |
call refresh function for all objects currently on screen. More... | |
void | objUpdateAll (void) |
call update function for all objects currently active (if they are in "virtual screen" coordinates). More... | |
void | objUpdateXY (u16 objhandle) |
Update X & Y coordinates of object regarding its own velocitys. More... | |
Variables | |
t_objs | objbuffers [OB_MAX] |
current object buffer with all objects | |
u16 | objgetid |
id of current object (useful when creating it) | |
u16 | objptr |
pointer to current object | |
u8 | objtokill |
put 1 in variable to kill current object | |
snes object engine functionality.
64 maximum of objects managed by engine
32 type of objects maximum by engine
#define OB_MAX 64 |
total number of objects in the game
#define OB_TYPE_MAX 64 |
total number of type of objects in the game
objCollidMap | ( | u16 | objhandle | ) |
check if an object collides the map
objhandle | handle of the object |
update tilestand, tileabove with tiles on map regarding object attributes
update xvel, yvel with velocity regarding tiles on map
objCollidMap1D | ( | u16 | objhandle | ) |
check if an object collides the map
objhandle | handle of the object |
update tilestand, tileabove with tiles on map regarding object attributes
update xvel, yvel with no gravity regarding tiles on map
objCollidMapWithSlopes | ( | u16 | objhandle | ) |
check if an object collides the map with map slopes management
objhandle | handle of the object |
update tilestand, tileabove with tiles on map regarding object attributes
update xvel, yvel with velocity regarding tiles on map
the map can contain slopes, check the constants ($20..$25) the add them to your map
objCollidObj | ( | u16 | objhandle1, |
u16 | objhandle2 | ||
) |
check if two objects are colliding
objhandle1 | handle of the 1st object |
objhandle2 | handle of the 2nd object |
objGetPointer | ( | u16 | objhandle | ) |
get the pointer to an object from its handle (need to do -1 to have offset after), objptr will has the pointer of the object
objhandle | handle of the object |
objInitFunctions | ( | u8 | objtype, |
void * | initfct, | ||
void * | updfct, | ||
void * | reffct | ||
) |
Initialize the object type functions (initialize, update)
objtype | The type of object depending of the game |
initfct | The address of the function when we init the type of object |
updfct | The address of the function when we update the type of object (need to be called once per frame) |
reffct | The address of the function when we refresh sprites of object (need to be called once per frame) |
init function must have 5 unsigned short (u16) parameters
update function must have 1 parameter
refresh function must have 1 parameter
objKill | ( | u16 | objhandle | ) |
kill an object from the game
objhandle | handle of the object |
objLoadObjects | ( | u8 * | sourceO | ) |
Load all objects for a specific table in memory.
sourceO | table of objects |
Call, after loading, each init function of the type of objects for each object
The table has an entry with x,y,type,minx,maxx for each object
the last four parameters are useful to do some actions where minimum or maximum is reached
The table needs to finish with FFFF to indicate that no more objects are availables
objNew | ( | u8 | objtype, |
u16 | x, | ||
u16 | y | ||
) |
Initialize a new object in game, objgetid will has the id of the object.
objtype | The type of object depending of the game |
x | The X coordinate of object on map or screen |
y | The Y coordinate of object on map or screen |
objRefreshAll | ( | void | ) |
call refresh function for all objects currently on screen.
useful to avoid flickering when using a platform scrolling game.
screen coordinates are -32<x<256 and -32<y<y<224.
objUpdateAll | ( | void | ) |
call update function for all objects currently active (if they are in "virtual screen" coordinates).
"virtual screen" coordinates are -64<x<320 and -64<y<288.
objUpdateXY | ( | u16 | objhandle | ) |
Update X & Y coordinates of object regarding its own velocitys.
objhandle | handle of the object |
It uses xvel and yvel to do such computation