Text Based Game
Hey Guys,
I started to program a text based game in c++ using VStudio6.0 which is like the "earth 2025" online text game.
I decided to make it a single player, single enemy game where you build up your empire and armies to defeat the enemy.
I am trying to figure out ways to keep the code as simple and as clean as possible, so i decided to use classes. But now I'm stuck as I'm not sure how many classes to make? I was thinking of having a single class called cEngine that held two player structures; one for the main player and one for the randomly generated enemy. It would also have the menu functions such as saving, loading, character creation and exiting the game ( as well as the build and attack functions and such).
Is this good coding style or should I have separate classes for players, menus and attacking?
edit-typo
[Edited by - Sabonis on August 29, 2005 3:09:42 PM]
Although I'm not the guru you're asking for, I would make every player just one class. you could derive a class for a human player or visa-versa. you could simply call a function which performs the AI... But I would go for the single class, that way you can expand the game to include as many players as you want.
There are so many ways to make it, it's kind of hard to say...
There are so many ways to make it, it's kind of hard to say...
Quote:Original post by SabonisIs this good coding style or should I have separate classes for players, menus and attacking?
Your approach is perfectly fine.
It really depends on your coding style, some people code with the fewest classes they can have, others (like myself) create classes liberally. Basically, if you can think of something as a tangible object, you can create a class for it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement