# Thread: Which One Would Take Up the Least space

1. ## Which One Would Take Up the Least space

Here's what I need in my structs. I need a player struct that contains x, y, exists, and frame. A bullet[#] struct that contains x, y, exists, and type. An enemy[#] struct that contains x[#], y[#], exists[#], type[#], and frame[#]. An enemy bullet struct that contains x[#], y[#], exists[#], and type[#]. My questions is out of the two examples I've shown which one is the best to use. I'm assuming that it's example 1, but the only reason for my doubt is because there are wasted integers for two structs. Both player bullets and enemy bullets aren't going to be using int frame. So which one is better to use.

example 1
Code:
```struct PLAYERS
{
int x;
int y;
int exists;
int type;
int frame;
}bullet[PL_MAX_BULLETS], player;

struct ENEMIES
{
int x[MAX_ENEMIES];
int y[MAX_ENEMIES];
int exists[MAX_ENEMIES];
int frame[MAX_ENEMIES];
int type[MAX_ENEMIES];
}e_bullet[MAX_ENEMIES], enemy[MAX_ENEMIES];```
example 2
Code:
```struct BULLETS
{
int x;
int y;
int exists;
int type;
}bullet[PL_MAX_BULLETS];

struct PLAYERS
{
int x;
int y;
int exists;
int frame;
}player;

struct ENEMY_BULLETS
{
int x[MAX_ENEMIES];
int y[MAX_ENEMIES];
int exists[MAX_ENEMIES];
int type[MAX_ENEMIES];
}e_bullet[MAX_ENEMIES];

struct ENEMIES
{
int x[MAX_ENEMIES];
int y[MAX_ENEMIES];
int exists[MAX_ENEMIES];
int type[MAX_ENEMIES];
int frame[MAX_ENEMIES];
}enemy[MAX_ENEMIES];```
*I'm not really sure why I'm asking this, because I already know it's example 1. I guess sometimes you just need reassurance... And btw, if anybody has a better example (idea) please feel free to share it.

2. Code:
```struct ENEMIES
{
int x[MAX_ENEMIES];
int y[MAX_ENEMIES];
int exists[MAX_ENEMIES];
int frame[MAX_ENEMIES];
int type[MAX_ENEMIES];
}e_bullet[MAX_ENEMIES], enemy[MAX_ENEMIES];```
should be
Code:
```struct ENEMIES
{
int x;
int y;
int exists;
int frame;
int type;
}e_bullet[MAX_ENEMIES], enemy[MAX_ENEMIES];```

3. Think about it
Oh yeah, you're right; I'm not sure what I was thinking.

In fact, right now I'm trying to figure out what I was thinking. I guess that's pretty hard to do when I must have not been thinking at all...

4. Yea, I was wondering how someone as mighty and allpowerful as you could make that mistake

5. yeah, no kidding. all the planets must be alligned or sumpin...

6. Hey, 400 posts for you, now you can have that custom text stuff. What's it gonna be?

7. well, i still don't see the option to do that, so i'm not sure.

8. wait i know what i was thinking.

the struct for the enemies is going to have to be like this (there is another method i could use but this way seems the easiest)

Code:
```struct ENEMIES
{
int x[MAX_ENEMIES];
int y[MAX_ENEMIES];
int exists[MAX_ENEMIES];
int type[MAX_ENEMIES];
int frame;
}e_bullet[MAX_ENEMIES], enemy[MAX_ENEMIES];```
Because each enemy is going to have a set of set bullets. Since I'm going to have more than one enemy at a time each enemy is going to have a set of bullets. If I don't use arrays for x, y, exists, and type then I'm going to have a huge list of bullets that will not be coordinated with each enemy. I need the sets of bullets to be linked with it's own enemy that way I can keep track of how many bullets each enemy has shot at a time. Does this make sense?

Here's an example of what I'm saying:

enemy one shoots

e_bullet[0].x[0]
e_bullet[0].y[0]
e_bullet[0].exists[0]
e_bullet[0].type[0]

then enemy two shoots

e_bullet[1].x[0]
e_bullet[1].y[0]
e_bullet[1].exists[0]
e_bullet[1].type[0]

enemy two shoots again

e_bullet[1].x[1]
e_bullet[1].y[1]
e_bullet[1].exists[1]
e_bullet[1].type[1]

Basically there are going to be so many enemies shooting at once that I'm going to need the arrays set like that. Hey, I guess I knew what I was talking about; for some reason I couldn't figure it out after you pointed out to me that I had it like that.

9. Why not have one pool of enemies and one pool of bullets?

Each time an enemy shoots a bullet from the bullet pool is used.

10. Why not have one pool of enemies and one pool of bullets?
Well, because each enemy is going to have a different set of information pertaining to it, and the same goes with the bullets. I soon realized after I wrote that I'm going to have to include two nested structs. One is going to be for the info for the bullets and the other is going to be for the info for the enemies; however, I might be able to combine it into one struct; I'm not sure.

Having it set up like this is going to allow me to have a many different type of bullets and many different types of enemies that all have different values.

Popular pages Recent additions