Hey folks, I was thinking about two possibilities of updating graphics and other things, and I wondered what the best option may be.
The first idea was to create a thread for each update (One for graphics, one for physics, and perhaps one for keeping time).
This may be very helpful as it should, in theory, update everything at the same time.
Surely, this would have some strain on the GPU and CPU, especially if there are hundreds of thousands of polygons being rendered while doing the math for physics etc...
The second idea is more simple. Create a class which looks like so:
class Foo
{
public:
Foo(){}
~Foo(){}
void operate(){}
}
Now, class A, B, C could be used via polymorphism with Foo to update a certain part of the game, like so:
class A : public Foo
{
public:
A(){/*Do stuff*/}
A(){/*Do stuff*/}
void operate()
{/*Update graphics*/}
}
class B : public Foo
{
public:
B(){/*Do stuff*/}
B(){/*Do stuff*/}
void operate()
{/*Update Physics*/}
}
class B : public Foo
{
public:
B(){/*Do stuff*/}
B(){/*Do stuff*/}
void operate()
{/*Update time-keeping*/}
}
Which method would you recommend for casual use?
Is there a better alternative to both of them which I'm too blind to realise?
Help would be appreciated.