A game with a console interface and GUI
Hello everyone,
I'm writing a small strategy game in C (not C++) and plan on implementing a console version (curses) for various systems, as well as a GUI version (SDL maybe). The problem is, I don't know exactly how to go about organizing my code.
I know that I must separate the game's core code from the user interface code, but I don't know the best way to organize it all. I would also like to keep the code easily portable between systems as well. If anyone knows of a working example of such a program, or has some tips, I would be very grateful.
Thank you for your time.
What you could (should?) do is essentially design an interface of all the functions your console/SDL code will call. They dont need to know HOW it works, just THAT it works.
For instance, a move command for a unit would be completely defined in the unit (or game, or map or world class) but it would be accessible by the window/console in some way. For instance, pressing a move button and then a location would call the 'move(unit, location)' method which would handle everything.
Drawing stuff should be a factor of retrieving information from another class, not from within the interface class. For example:
For instance, a move command for a unit would be completely defined in the unit (or game, or map or world class) but it would be accessible by the window/console in some way. For instance, pressing a move button and then a location would call the 'move(unit, location)' method which would handle everything.
Drawing stuff should be a factor of retrieving information from another class, not from within the interface class. For example:
for(int i = 0; i < game->units.size(); i++){ if(game->units.within(screen)) drawUnit(&game->units);}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement