Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C Game Logic

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.

Name: Anonymous 2012-03-22 10:11

>>4
The function would get the "reintepreted object", and then execute the code at the starting point of that object. The function in question can then modify the objects data since it has the objects identifier. Now I would say read SICP, but like, you seem kind of confused about, well, everything.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List