PVSnesLib  3.4.0
Functions | Variables
object.h File Reference

snes object engine functionality. More...

#include <snes/snestypes.h>

Go to the source code of this file.

Functions

void objCollidMap (u16 objhandle)
 check if an object collides the map 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)
 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 objUpdateAll (void)
 call update fonction for all objects currently active
 
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
 

Detailed Description

snes object engine functionality.

64 maximum of objects managed by engine 32 type of objects maximum by engine

Function Documentation

◆ objCollidMap()

objCollidMap ( u16  objhandle)

check if an object collides the map

update tilestand, tileabove with tiles on map regarding object attributes update xvel, yvel with velocity regarding tiles on map

Parameters
objhandlehandle of the object

◆ objCollidObj()

objCollidObj ( u16  objhandle1,
u16  objhandle2 
)

check if two objects are colliding

Parameters
objhandle1handle of the 1st object
objhandle2handle of the 2nd object
Returns
1 if collision detected, 0 elsewhere

◆ objGetPointer()

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

Parameters
objhandlehandle of the object
Examples:
objects/moveobjects/moveobjects.c.

◆ objInitFunctions()

objInitFunctions ( u8  objtype,
void *  initfct,
void *  updfct 
)

Initialize the object type functions (initialize, update)

Parameters
objtypeThe type of object depending of the game
initfctThe address of the function when we init the type of object
updfctThe address of the function when we update the type of object (will be called once per frame)
Examples:
objects/moveobjects/moveobjects.c.

◆ objKill()

objKill ( u16  objhandle)

kill an object from the game

Parameters
objhandlehandle of the object

◆ objLoadObjects()

objLoadObjects ( u8 *  sourceO)

Load all objects for a specific table in memory.

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 where: x,y are coordinates of object, type if the type of the object (maximum 32 types) minx,maxx are the coordinates of minimum & maxinmum possible on x miny,maxy are the coordinates of minimum & maxinmum possible on y 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

Parameters
sourceOtable of objects
Examples:
objects/moveobjects/moveobjects.c.

◆ objNew()

objNew ( u8  objtype,
u16  x,
u16  y 
)

Initialize a new object in game, objgetid will has the id of the object.

Parameters
objtypeThe type of object depending of the game
xThe X coordinate of object on map or screen
yThe Y coordinate of object on map or screen
Returns
id of the object in object id table
Examples:
objects/moveobjects/moveobjects.c.

◆ objUpdateXY()

objUpdateXY ( u16  objhandle)

Update X & Y coordinates of object regarding its own velocitys.

It uses xvel and yvel to do such computation

Parameters
objhandlehandle of the object