(Borland C++ Free Command Line Compiler, WinXP)
Ok, I'm having a bit of a deilema, this code goes on for about 10-20 seconds before completing, and the loop only runs twelve times... It shouldent be this slow, and it doesnt really work as every time I call this it makes a very long wait.
Platform class <-> (Do I need to make my class support vectors?)
Code:
class Platform {
private:
SHORT Strength;
SHORT SteppedOn;
SHORT x;
SHORT y;
public:
Platform() {Strength=1; SteppedOn=0; x=0; y=0;}
Platform(SHORT str, SHORT Step, SHORT x_pos, SHORT y_pos) {Strength=str; SteppedOn=Step; x=x_pos; y=y_pos;}
void Set(SHORT str, SHORT Step, SHORT x_pos, SHORT y_pos) {Strength=str; SteppedOn=Step; x=x_pos; y=y_pos;}
SHORT GetX() {return x;}
SHORT GetY() {return y;}
SHORT GetStr() {return Strength;}
SHORT GetWStatus() {return SteppedOn;}
void Reset() {Strength=1; SteppedOn=0; x=0; y=0;}
};
Called function:
Code:
//Wall8 is '-' its declared in another portion of code.
Platform FindPlatform() {
int x_pos, y_pos, MPR;
Platform MOR;
char Ac[1];
for(y_pos=1; y_pos <= 23; y_pos++)
for(x_pos=1; x_pos <= 78; x_pos++) {
Ac[0]=ReadPos(x_pos, y_pos);
if(Ac[0] == Wall8)
MOR.Set(1, 0, x_pos, y_pos);
return MOR;
}
return MOR;
}
Main body:
Code:
int LINE() {
int x, TotalPlats;
vector <Platform> Plat;
TotalPlats=12;
for(x=0; x < TotalPlats; x++)
Plat.push_back(FindPlatform());
}
This is going way to slow. is it the vectors or the function or what?