switch (nScene)
{
case 0:
Scene_0(lCurrTime, lStartTime);
break;
case 1:
Scene_1(lCurrTime, lStartTime);
break;
default:
break;
}
just 2 cases in the above code. how would i make this more variable like so i can easily put this in a loop instead of having 100 case statements?
thuned
life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
variable function calling
have something like this
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
Function pointers
typedef void (*fptrScene)(time lCurrTime, time lStartTime);
fptrScene SceneArray[20];
Scene_0(time lCurrTime, time lStartTime);
Scene_1(time lCurrTime, time lStartTime);
Scene_2(time lCurrTime, time lStartTime);
then in your init function somewhere:
...
SceneArray[0] = Scene_0;
SceneArray[1] = Scene_1;
SceneArray[2] = Scene_2;
...
Then for your loop
... I think. Don''t quote me on that though, I have never made an array of function pointers. In theory it should work
-Chris Bennett of Dwarfsoft - The future of RPGs Thanks to all the goblins in the GDCorner niche
typedef void (*fptrScene)(time lCurrTime, time lStartTime);
fptrScene SceneArray[20];
Scene_0(time lCurrTime, time lStartTime);
Scene_1(time lCurrTime, time lStartTime);
Scene_2(time lCurrTime, time lStartTime);
then in your init function somewhere:
...
SceneArray[0] = Scene_0;
SceneArray[1] = Scene_1;
SceneArray[2] = Scene_2;
...
Then for your loop
|
... I think. Don''t quote me on that though, I have never made an array of function pointers. In theory it should work
-Chris Bennett of Dwarfsoft - The future of RPGs Thanks to all the goblins in the GDCorner niche
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement