Entity

Basic entity class.

Summary
EntityBasic entity class.
Functions
destroyDestorys the entity.
resetCalled when the game resets the map.
tickCalled progress the entity to the next tick.
tick_deferedCalled after all entities tick() function has been called.
snapCalled when a new snapshot is being generated for a specific client.
Variables
proximity_radiusContains the physical size of the entity.
posContains the current posititon of the entity.
Game WorldTracks all entities in the game.
Functions
find_entitiesFinds entities close to a position and returns them in a list.
interserct_characterFinds the closest character that intersects the line.
closest_characterFinds the closest character to a specific point.
insert_entityAdds an entity to the world.
remove_entityRemoves an entity from the world.
destroy_entityDestroys an entity in the world.
snapCalls snap on all the entities in the world to create the snapshot.
tickCalls tick on all the entities in the world to progress the world to the next tick.
Game ControllerControls the main game logic.
Functions
on_entityCalled when the map is loaded to process an entity in the map.
on_character_spawnCalled when a character spawns into the game world.
on_character_deathCalled when a character in the world dies.

Functions

destroy

virtual void destroy()

Destorys the entity.

reset

virtual void reset()

Called when the game resets the map.  Puts the entity back to it’s starting state or perhaps destroys it.

tick

virtual void tick()

Called progress the entity to the next tick.  Updates and moves the entity to it’s new state and position.

tick_defered

virtual void tick_defered()

Called after all entities tick() function has been called.

snap

virtual void snap(int snapping_client)

Called when a new snapshot is being generated for a specific client.

Arguments

snapping_clientID of the client which snapshot is being generated.  Could be -1 to create a complete snapshot of everything in the game for demo recording.

Variables

proximity_radius

float proximity_radius

Contains the physical size of the entity.

pos

vec2 pos

Contains the current posititon of the entity.

Game World

Tracks all entities in the game.  Propagates tick and snap calls to all entities.

Summary
Functions
find_entitiesFinds entities close to a position and returns them in a list.
interserct_characterFinds the closest character that intersects the line.
closest_characterFinds the closest character to a specific point.
insert_entityAdds an entity to the world.
remove_entityRemoves an entity from the world.
destroy_entityDestroys an entity in the world.
snapCalls snap on all the entities in the world to create the snapshot.
tickCalls tick on all the entities in the world to progress the world to the next tick.

Functions

find_entities

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.

Arguments

posPosition.
radiusHow close the entities have to be.
entsPointer to a list that should be filled with the pointers to the entities.
maxNumber of entities that fits into the ents array.
typeType of the entities to find.  -1 for all types.

Returns

Number of entities found and added to the ents array.

interserct_character

Finds the closest character that intersects the line.

Arguments

pos0Start position
pos2End position
radiusHow for from the line the character is allowed to be.
new_posIntersection position
notthisEntity to ignore intersecting with

Returns

Returns a pointer to the closest hit or NULL of there is no intersection.

closest_character

class CHARACTER *closest_character(vec2 pos,
float radius,
ENTITY *notthis)

Finds the closest character to a specific point.

Arguments

posThe center position.
radiusHow far off the character is allowed to be
notthisEntity to ignore

Returns

Returns a pointer to the closest character or NULL if no character is close enough.

insert_entity

void insert_entity(ENTITY *entity)

Adds an entity to the world.

Arguments

entityEntity to add

remove_entity

void remove_entity(ENTITY *entity)

Removes an entity from the world.

Arguments

entityEntity to remove

destroy_entity

void destroy_entity(ENTITY *entity)

Destroys an entity in the world.

Arguments

entityEntity to destroy

snap

void snap(int snapping_client)

Calls snap on all the entities in the world to create the snapshot.

Arguments

snapping_clientID of the client which snapshot is being created.

tick

void 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.  Keeping track of team and player score, winning conditions and specific game logic.

Summary
Functions
on_entityCalled when the map is loaded to process an entity in the map.
on_character_spawnCalled when a character spawns into the game world.
on_character_deathCalled when a character in the world dies.

Functions

on_entity

virtual bool on_entity(int index,
vec2 pos)

Called when the map is loaded to process an entity in the map.

Arguments

indexEntity index.
posWhere the entity is located in the world.

Returns

bool?

on_character_spawn

virtual void on_character_spawn(class CHARACTER *chr)

Called when a character spawns into the game world.

Arguments

chrThe character that was spawned.

on_character_death

virtual int on_character_death(class CHARACTER *victim,
class PLAYER *killer,
int weapon)

Called when a character in the world dies.

Arguments

victimThe character that died.
killerThe player that killed it.
weaponWhat weapon that killed it.  Can be -1 for undefined weapon when switching team or player suicides.
virtual void destroy()
Destorys the entity.
virtual void reset()
Called when the game resets the map.
virtual void tick()
Called progress the entity to the next tick.
virtual void tick_defered()
Called after all entities tick() function has been called.
virtual void snap(int snapping_client)
Called when a new snapshot is being generated for a specific client.
float proximity_radius
Contains the physical size of the entity.
vec2 pos
Contains the current posititon of the entity.
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.
class CHARACTER *closest_character(vec2 pos,
float radius,
ENTITY *notthis)
Finds the closest character to a specific point.
void insert_entity(ENTITY *entity)
Adds an entity to the world.
void remove_entity(ENTITY *entity)
Removes an entity from the world.
void destroy_entity(ENTITY *entity)
Destroys an entity in the world.
void snap(int snapping_client)
Calls snap on all the entities in the world to create the snapshot.
void tick()
Calls tick on all the entities in the world to progress the world to the next tick.
virtual bool on_entity(int index,
vec2 pos)
Called when the map is loaded to process an entity in the map.
virtual void on_character_spawn(class CHARACTER *chr)
Called when a character spawns into the game world.
virtual int on_character_death(class CHARACTER *victim,
class PLAYER *killer,
int weapon)
Called when a character in the world dies.
Close