Name: Anonymous 2012-03-22 6:28
How should I setup my game logic in C? I'm not entirely sure how I can set it up without using classes.
For example, in C++ it works like:
MainMenuWorld and LevelWorld both extend WorldBase class.
WorldBase *TargetWorld;
TargetWorld = new MainMenuWorld();
//or
TargetWorld = new LevelWorld();
Then, for the logic:
TargetWorld -> input(event);
...
TargetWorld -> draw();
...
TargetWorld -> update();
Should I use a variable to determine what to render? i.e. 1 = MainMenuWorld, 2 = LevelWorld, etc. That feels like it might be a bit of a performance problem though, so I'm not exactly sure. I'm also using C because the psp homebrew compiler doesn't like C++.
I was thinking having methods that work like "ChangeWorld(Worlds::MainMenu);" but I'm not really sure what I should have the method do.
For example, in C++ it works like:
MainMenuWorld and LevelWorld both extend WorldBase class.
WorldBase *TargetWorld;
TargetWorld = new MainMenuWorld();
//or
TargetWorld = new LevelWorld();
Then, for the logic:
TargetWorld -> input(event);
...
TargetWorld -> draw();
...
TargetWorld -> update();
Should I use a variable to determine what to render? i.e. 1 = MainMenuWorld, 2 = LevelWorld, etc. That feels like it might be a bit of a performance problem though, so I'm not exactly sure. I'm also using C because the psp homebrew compiler doesn't like C++.
I was thinking having methods that work like "ChangeWorld(Worlds::MainMenu);" but I'm not really sure what I should have the method do.