Skip to content

create, render, and destroy entities

Fosowl edited this page May 30, 2020 · 2 revisions

Function that you can use to create render and destroy entities of the scene.

note : function for rendering only have to use if you are not the using the default function to update the engine ( starset_update_engine) or if you you want the force the rendering of an entities.

create entities and add it to the scene.

This function is use to add a new entities to the scene.

entities_t *starset_entities_add(entities_t *entities_list , char *source, char *name, sfBool fixed);

parameter

entities_t *entities_list : the chain list of all entities on the scene.

char *source : the path to the texture for the entities.

char *name : the name this new entities.

sfBool fixed : put true if the entities should not be moved when colliding, false otherwise.

create entities from prefab

create new entities from a sprite prefab this allow you safe memory when working with many entities that use the same texture

entities_t *starset_entities_add_from_prefab(entities_t *entities_list , sfSprite *prefab, char *name, sfBool fixed);

parameter

entities_t *entities_list : the chain list of all entities on the scene.

sfSprite *prefab : prefab sprite to use.

char *name : the name of the new entities.

sfBool fixed : put true if the entities should not be moved when colliding, false otherwise.

create a prefab

create a new prefab sprite from a texture.

sfSprite *starset_create_prefab(char *source);

parameter

char *source : the source path of the function.

add obstacle entities

add an invisible wall to the scene.

entities_t *starset_add_obstacle_entities(entities_t *entities_list , sfVector2f spot, sfVector2f size);

parameter

entities_t *entities_list : the chain list of all entities on the scene.

sfVector2f spot : position of this invisible entities.

sfVector2f size : size of this invisible entities.

render single entities

render a single entities on the scene.

void starset_entities_render_single(entities_t *copy, sfRenderWindow *window);

parameter

entities_t *copy : pointer to the entities that need to be rendered.

sfRenderWindow *window : the game window.

render every entities on the scene

render every entities on the scene note that starset_entities_update already take care of rendering all entities.

void starset_entities_render_all(entities_t *entities, sfRenderWindow *window);

parameter

entities_t *entities_list : the chain list of all entities on the scene.

sfRenderWindow *window : the game window.

destroy single entities

destroy a single entities giving its name.

parameter

entities_t *starset_entities_destroy(entities_t *entities, char *name);

entities_t *entities_list : the chain list of all entities on the scene.

char *name : name of the entities to destroy.

destroy all entities

destroy all entities on the scene

parameter

void starset_entities_destroy_all(entities_t *entities);

entities_t *entities : destroy all entities on the scene.