Best way to incorporate upgrades

This is a discussion on Best way to incorporate upgrades within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hello I have been working on a game for the past two weeks called "Revolting aginst a super power". It's ...

  1. #1
    Shadow12345
    Guest

    Best way to incorporate upgrades

    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.

  2. #2
    Shadow12345
    Guest
    Here is the basic story line of the game:
    Code:
    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!

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    i would personally go with using the classes, not the enumerated data type. when in doubt, classes are good.
    My Website

    "Circular logic is good because it is."

  4. #4
    Shadow12345
    Guest
    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:
    Code:
    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.
    Last edited by Shadow12345; 09-26-2002 at 08:44 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. first look incorporate assembly?
    By stabu in forum C Programming
    Replies: 8
    Last Post: 09-25-2008, 09:53 AM
  2. Incorporate an existing program into another?
    By thetinman in forum Windows Programming
    Replies: 5
    Last Post: 06-06-2008, 09:40 AM
  3. How can I incorporate this code into a web page?
    By MisterRob in forum C Programming
    Replies: 6
    Last Post: 11-02-2005, 05:43 PM
  4. computer upgrades
    By major_small in forum Tech Board
    Replies: 2
    Last Post: 05-13-2004, 12:21 PM
  5. How can I incorporate Assembly code in my C++ program.
    By bman1176 in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2001, 10:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21