PDA

View Full Version : Best way to incorporate upgrades



Shadow12345
09-25-2002, 12:16 PM
Hello I have been working on a game for the past two weeks called "Revolting aginst a super power". It's a game that takes place in space, and you are basically a missionary trying to get planets and civilizations to revolt agains the corrupt, evil govt. So far I have the basic spaceship physics complete (it tilts sideways when moving side to side, tilts forward when moving up and down, I have some special features i.e spheres that hover around it). Now I am designing how the upgrades will work. There will be ship and weapons upgrades that the player will encounter throughout the game. Here is where it may get tricky. I could have an enumerated constant describing all of the weapons as members of the spaceship class, and depending what weapons are currently available decides what is actually drawn. OR I could have a weapon class as an abstract data type and each new weapon inherits all of the weapon features plus ones peculiar to its type (for example a homing missles and machine guns). Whenever an upgrade is acquired a new weapon object is created and the previous obsolete weapon objects are deleted.

I hope I have made my point clear. I would like suggestions to what i have said or original suggestions that may help with my problem.

Thanks.

Shadow12345
09-25-2002, 12:18 PM
Here is the basic story line of the game:


Summary:

The government reserves absolute and total control. Money isn't being spent on the sick and resources are so tightly controlled that progress and economy

suffer. The 100 year revolution has increased the government's power. They now control most of the planets that have ever existed. They go from location to

location with their military and force the people into selling their resources for unfair prices. When uprisings occur the people are killed. All of them.

Your name is Frank Barone, you have been called upon by a small rebel group called Phoenix Underground

to help take control away from the government and reinstate it back to the people. This group

is well financed by anonymous patrons who believe in taking power away from the government.

How the game is played:

At any one time you are in a section of space. This section of space can contain:

Any number of government units (depending on the 'level' that you are currently in)

Any number of planets (also depending on the 'level')

Other obstacles that remain unthought of

Your objective is to Liberate and Free Planets you do this by:

Earning money and giving it to the people

Freeing planets

Starting revolts against the government.

You can win the game by:

Having more than %90 planets that are liberated


Tell me what you think! :)

DavidP
09-25-2002, 02:15 PM
i would personally go with using the classes, not the enumerated data type. when in doubt, classes are good.

Shadow12345
09-26-2002, 07:41 AM
Yes I do think I will end up using classes. I am not exaclty sure how to have a class as a member of another class. Do I declare and define the Weapon class(which is a member of the Spaceship class) and then just have an instance of the class as the desired member variable. If someone could show me an example using empty classes that would be helpful.

Also, I have Weapon as an abstract data type, and I am thinking of having another class/struct/union/enumerated type that describes the type of damage that the weapon inflicts (i.e damages metal more than planets)

EDIT:
This is what I have so far for an empty Weapon class, I'm just not sure how I can incorporate it with the Spaceship class:


class Weapon { //ABSTRACT DATA TYPE, EACH SPAESHIP HAS A WEAPON
public:
float AttackValue; //HOW MUCH DAMAGE IT CAUSES
bool Attacking; //WHETHER OR NOT THE WEAPON IS IN ATTACKING MODE

private:
};

class Weapon1 : public Weapon{ //EACH NEW WEAPON NEEDS A SPECIFIC DEFAULT CONSTRUCTOR
public:
private:
};

class Weapon2 : public Weapon{
public:
private:
};

class Weapon3 : public Weapon{
public:
private:
};


Also:
Do you think it would be a good idea to use an array to describe the type of damage the weapon causes? For example:
float Damage = { 0.0f, 1.0f, .5f};
That could be use to describe the type of damage that the weapon causes, for example the first element of the array could describe the damage against metal, the second in the array could describe damage against planets, the third element could describe damage against something else in the game.