Multiple objects problem.

Hello world!!
I need help with somethig that makes me angry every ime that i wnat to do it.
Lets say that i got a class that have all the things that have a monster health, attack function, damage.... and i want to like loop the monster as many times as i want (like doombuilder that you can make as many monsters as you can) like a sizeble array. can someone help me? thanks if someone can answer this.

(sorry for my grammar if somhthink is wronge. im learning english)
If I understood you correctly, you're looking for a std::vector. Look it up and see if it's what you need.
You probably need an object to hold the state: health, attack function, damage etc.

Your loop updates the object's state on each iteration. I don't think there' an array issue. You may need an array or list of monsters that are updated each time thru the loop, but that's slightly different.
I need the staff like the videogames that have like mutltiple obejects in the world and i dont understand very well those vectores but thx for the help
Maybe some code would help explain what you mean?
class Actor_s
{
public:
int a_health;
int a_damage;
int a_vel;
double a_x;
double a_y;
double a_cansee;
Direction DIR;

bool WakeUp();
int a_distance (double x1, double y1, double x2, double y2);
void a_move (double x2, double y2);
void a_attack (double selecthealth);

};

i call it actore to represent somthing alive like a human, monster, enemy etc.
then i wnat like make a monster

Actor_s monster1;

but i wnat to multiplay as many times as i want like a map editor or somthing
You can store the multiple instances of class Actor_s in a container. If there's a lot of deletion/insertion going on, a std::list is the best approach ( http://www.cplusplus.com/reference/stl/list/ ). Then you just loop through the instances and update them or whatever.
Step by step im leraning ponters right now i can learn all at the same time but i will try thx for all the answers!! i dont understand list and vectores but can someone do somthing simple. actuali i take a look on de code of the game doom they dont use that the using like pointers in C

Check out the arrays/pointers in the tutorial. In C, there are no STL containers but in C++ they would be the way to go.
http://www.cplusplus.com/doc/tutorial/
Even if Doom had been written in C++ (my guess is it was written in C, but I don't really know), the STL wasn't part of C++ back in the early 90's.
And if someone is interested in the sourcecode of doom. Here's a nice place to start -> http://www.doomworld.com/classicdoom/ports/
Topic archived. No new replies allowed.