The gameloop - mrpedrobraga/Toyvox GitHub Wiki

Where your game's logic takes place.

Scenes have another function called every_tick, that you can implement just like you did with on_load. If the scene in question is the current scene, this function is called at every update.

scene.every_tick=[](){
   //Useful things to do.
}

Let's say we have a component type Position, a struct that contains a single glm::vec3, and we want to increase the z of ALL entities at every tick?

scene.every_tick=[scene&](){
   scene.componentHandler.get_c("Position")->apply(&increaseZ);
}

Where "increaseZ" is a function as follows (again, you can use lambda expressions if you want to):

void increaseZ(Position p)
{
p.z += 100 * DELTA_TIME;
}

'DELTA_TIME' is a variable given by Toyvox. It marks how much time passed since the last frame in seconds. 1/DELTA_TIME equals the framerate.

Nice, but how do I make my game run?