Basic entity class.
Entity | Basic entity class. |
Functions | |
destroy | Destorys the entity. |
reset | Called when the game resets the map. |
tick | Called progress the entity to the next tick. |
tick_defered | Called after all entities tick() function has been called. |
snap | Called when a new snapshot is being generated for a specific client. |
Variables | |
proximity_radius | Contains the physical size of the entity. |
pos | Contains the current posititon of the entity. |
Game World | Tracks all entities in the game. |
Functions | |
find_entities | Finds entities close to a position and returns them in a list. |
interserct_character | Finds the closest character that intersects the line. |
closest_character | Finds the closest character to a specific point. |
insert_entity | Adds an entity to the world. |
remove_entity | Removes an entity from the world. |
destroy_entity | Destroys an entity in the world. |
snap | Calls snap on all the entities in the world to create the snapshot. |
tick | Calls tick on all the entities in the world to progress the world to the next tick. |
Game Controller | Controls the main game logic. |
Functions | |
on_entity | Called when the map is loaded to process an entity in the map. |
on_character_spawn | Called when a character spawns into the game world. |
on_character_death | Called when a character in the world dies. |
Tracks all entities in the game. Propagates tick and snap calls to all entities.
Functions | |
find_entities | Finds entities close to a position and returns them in a list. |
interserct_character | Finds the closest character that intersects the line. |
closest_character | Finds the closest character to a specific point. |
insert_entity | Adds an entity to the world. |
remove_entity | Removes an entity from the world. |
destroy_entity | Destroys an entity in the world. |
snap | Calls snap on all the entities in the world to create the snapshot. |
tick | Calls tick on all the entities in the world to progress the world to the next tick. |
int find_entities( vec2 pos, float radius, ENTITY ** ents, int max, int type = -1 )
Finds entities close to a position and returns them in a list.
pos | Position. |
radius | How close the entities have to be. |
ents | Pointer to a list that should be filled with the pointers to the entities. |
max | Number of entities that fits into the ents array. |
type | Type of the entities to find. -1 for all types. |
Number of entities found and added to the ents array.
Finds the closest character that intersects the line.
pos0 | Start position |
pos2 | End position |
radius | How for from the line the character is allowed to be. |
new_pos | Intersection position |
notthis | Entity to ignore intersecting with |
Returns a pointer to the closest hit or NULL of there is no intersection.
class CHARACTER *closest_character( vec2 pos, float radius, ENTITY * notthis )
Finds the closest character to a specific point.
pos | The center position. |
radius | How far off the character is allowed to be |
notthis | Entity to ignore |
Returns a pointer to the closest character or NULL if no character is close enough.
Controls the main game logic. Keeping track of team and player score, winning conditions and specific game logic.
Functions | |
on_entity | Called when the map is loaded to process an entity in the map. |
on_character_spawn | Called when a character spawns into the game world. |
on_character_death | Called when a character in the world dies. |
virtual int on_character_death( class CHARACTER * victim, class PLAYER * killer, int weapon )
Called when a character in the world dies.
victim | The character that died. |
killer | The player that killed it. |
weapon | What weapon that killed it. Can be -1 for undefined weapon when switching team or player suicides. |
Destorys the entity.
virtual void destroy()
Called when the game resets the map.
virtual void reset()
Called progress the entity to the next tick.
virtual void tick()
Called after all entities tick() function has been called.
virtual void tick_defered()
Called when a new snapshot is being generated for a specific client.
virtual void snap( int snapping_client )
Contains the physical size of the entity.
float proximity_radius
Contains the current posititon of the entity.
vec2 pos
Finds entities close to a position and returns them in a list.
int find_entities( vec2 pos, float radius, ENTITY ** ents, int max, int type = -1 )
Finds the closest character to a specific point.
class CHARACTER *closest_character( vec2 pos, float radius, ENTITY * notthis )
Adds an entity to the world.
void insert_entity( ENTITY * entity )
Removes an entity from the world.
void remove_entity( ENTITY * entity )
Destroys an entity in the world.
void destroy_entity( ENTITY * entity )
Calls snap on all the entities in the world to create the snapshot.
void snap( int snapping_client )
Calls tick on all the entities in the world to progress the world to the next tick.
void tick()
Called when the map is loaded to process an entity in the map.
virtual bool on_entity( int index, vec2 pos )
Called when a character spawns into the game world.
virtual void on_character_spawn( class CHARACTER * chr )
Called when a character in the world dies.
virtual int on_character_death( class CHARACTER * victim, class PLAYER * killer, int weapon )