Hello all,
Up until this point I had no problem with my 3D Mesh Object class I used for my game engine, however, the larger and more advanced my game engine is becoming is obviously forcing me to, well, code it like an engine. So I'm making a .cpp/header for every class. One of these classes is my Objects class.
Since there's no way I have enough characters for this in my post, here's the code:
https://pastebin.com/p5jDiVhx
Now, having std::vector <Timer> Timers(NUM_OF_OBJECTS) worked perfectly in my main source file, so I'm guessing this has a lot to do with scope. For example, if I used
void Object::RotateOnTimer(float x, float y, float z, float time)
{
if (x)
Rotate(x + rot, 0);
if (y)
Rotate(y + rot, 1);
if (z)
Rotate(z + rot, 2);
if (Timers[iIndex].WaitMilliSeconds(time))
rot += 0.005f;
}
It worked perfectly. But by putting my class into its own cpp and header, I this is no longer possible. Only one object will rotate. It will only rotate Timers[0] of my vector and nothing after it. Look in the pastebin comment I made at the very bottom, I can get the others to rotate by simply using if(!Timers[iIndex].WaitMilliSeconds(..)) then they will rotate as well, which means it's returning false with every function in my Timer class within the vector except for the very first(0).
I can compensate and make my all objects rotate by literally copy and pasting the identical classes, Timer, Timer1, Timer2, Timer3, literally make different classes that are identical. Then it works. But that's hardly a solution.
What's going on here?