Well this is a monster class that loads monster data from a file the file contains simple data paths for the animations and such. I can spawn 80 monsters or so shoot emm up and whatnot, but then all of a sudden fstream doesnt populate temp and my frames count which causes the program to crash atm.
this is the file:
Code:
Spider_Walk/
12
Spider_Attack/
1
Spider_Die/
9
3
17 32 5 2
28 32 8 1
48 32 15 1
This is my constructor at the moment:
Code:
Monster::Monster(string filename,Resource_Manager *nrm)
{
rm = nrm;
//Class initalizations
Draw_Hit_Zones = true;
Draw_Health_Bar = true;
last_zone_hit = -1;
Dieing = false;
Time_Of_Death = 0;
cur_state = 0;
MAGIC = NULL;
delay = 100;
cur_frame = 0;
dr = 0;
r = 0;
Move_Speed = 10;
timer = clock();
Max_Hit_Points = 50;
Cur_Hit_Points = Max_Hit_Points;
//end class initalizations
stringstream ss;
string root_path = filename.substr(0,filename.find_last_of("/\\")+1); // /gfx/Spider/
string load_image_path;
string load_mask_path;
string temp;
ifstream load_file;
load_file.open(filename.c_str());
load_file>>temp>>W_num_frames;
W_ANI.assign(root_path);
W_ANI.append(temp);
load_file>>temp>>A_num_frames;
A_ANI.assign(root_path);
A_ANI.append(temp);
load_file>>temp>>D_num_frames;
D_ANI.assign(root_path);
D_ANI.append(temp);
rm->Load_Sprite(W_ANI,W_ANI);
rm->Load_Sprite(A_ANI,A_ANI);
rm->Load_Sprite(D_ANI,D_ANI);
magic_number = (int)ceil(sqrt(rm->Get_Sprite(W_ANI,0)->w*rm->Get_Sprite(W_ANI,0)->w + rm->Get_Sprite(W_ANI,0)->h*rm->Get_Sprite(W_ANI,0)->h));
load_file>>num_col;
Hit_Zones = new C_Circ*[num_col];
multipliers = new int[num_col];
int cx,cy,cr;
for(int lcv = 0;lcv < num_col;lcv++)
{
load_file>>cx>>cy>>cr>>multipliers[lcv];
Hit_Zones[lcv] = new C_Circ(cx+(magic_number-rm->Get_Sprite(W_ANI,0)->w)/2,cy+(magic_number-rm->Get_Sprite(W_ANI,0)->h)/2,cr);
}
Master_Hit_Zone = new C_Rect(x - (rm->Get_Sprite(W_ANI,0)->w/2),y - (rm->Get_Sprite(W_ANI,0)->h/2),rm->Get_Sprite(W_ANI,0)->w,rm->Get_Sprite(W_ANI,0)->h);
load_file.close();
}