Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Leyder Dylan

Structure for storing weapons

This topic is 5904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''ve a problem with my structure. I''d like to use a structure for storing the weapons + params and the bullet fired. Here''s my structure : // ********************************************** typedef struct { char Name[25]; float x, y, z; int Speed, Power; } WEAPON_CONFIG; // ********************************************** typedef struct { int Number_Weapon; WEAPON_CONFIG* Bullet; } WEAPON; For using the structure, I initialise it with : WEAPON Weapon_Use; And in my program, I use the structure like this : Weapon_Use.Bullet.Name[0] = ... Weapon_Use.Bullet[i].Power = ... etc ... In fact, I''d like to use a structure like this : Weapon_Use[0].Bullet[0].Power = ... The "Weapon_Use[]" variable will be used for storing each weapon (Desert Eagle, Magnum, ...) And the "...Bullet[]" variable will be used for each bullet fired. How can I adapt this structure : Weapon_Use.Bullet[0].Power In this : Weapon_Use[0].Bullet[0].Power Thanks in advance ... ======================== Leyder Dylan http://ibelgique.ifrance.com/Slug-Production/

Share this post


Link to post
Share on other sites
Advertisement

  WEAPON Weapon_Use[someNumberHere];
/*It's just making an array of structs. Or you could do it with a <vector>.*/
vector<WEAPON> Weapon_Use;


EDIT: Put in source tags cause it was taking out the vector tags
------------
aud.vze.com - The Audacious Engine <-- It's not much, yet. But it's mine... my own... my preciousssss...
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155

[edited by - LockePick on July 27, 2002 12:21:52 PM]

Share this post


Link to post
Share on other sites
I''ve made a mistake, here''s the new structure :


// **********************************************
typedef struct
{

char Name[25];
float x, y, z;
int Speed, Power;

} WEAPON_CONFIG;


// **********************************************
typedef struct
{

int Number_Weapon;
WEAPON_CONFIG* Weapon;

} WEAPON;

How can I adapt this structure :

Weapon_Use.Weapon[0].Power

In this :

Weapon_Use[0].Weapon[0].Bullet[0].Power

Thanks.

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!