on-internet
← Community

How do I implement a yield function for my game engine?

Stack Overflow ·

I have a game engine written in C. Every frame, it takes a list of game object structs, each of which has a "tick" function pointer that's executed every frame. However, some of these functions - or other functions called by them - use for loops that need to be executed over multiple frames. How could I implement a "yield" function that allows a function to wait for one executed frame before continuing? For better understanding, here's a pseudocode of my game engine's loop: game_t game; while (!game.shouldClose) { for (int i = 0; i < game.objects->len; i++) { object_t object = (object_t)list_g

Comments

Sign in or sign up to comment and upvote.

No comments yet.