views:

186

answers:

3

I've looked around for a simple design object in C++ to work from, i understand most of the code involved but i'm rather new to the language so a 'base' to work from would help.

Concept is basicly a 'task' class as a base for a jobs to run in a loop.

BaseTask class > AudioTask class

Controller loop > stores a std list of pointers to tasks running

while (false) { loop over list and run each pointer then start over }

Additional tasks can be inserted into the list adding to the loop as is required, providing the basis for practically anything to be run per frame of a game. Later on i hope to move onto threading etc but for now i just want something simple.

Does anyone know of or want to share some example code that would fit this pattern?

+1  A: 

A thread pool would fit the pattern.

It imposes the extra restrictions that jobs inserted into the thread pool (as functors) must be independent and thread-safe, but it processes all the jobs in parallel on a first-come-first-serve basis. (I'm actually using this idea as a basis for a project of my own.)

Although working with threads is probably not the greatest thing to do when you're already learning a language as complicated as C++, it is still a useful idea to explore.

greyfade
A: 

Read here for Game programming 101 part 1 and part 2.
From your question it seems that you are looking for threads and a game loop.
Start with a single threaded app and then move to multithreading since C++ is a language that is very hard to learn and even harder to master.

the_drow
A: 

You probably would be good with specialized threads communicating amongst themselves. There is a lightweight library which facilitates inter-thread messaging (LITM) with documentation.

jldupont