Jump to content
  • Advertisement
Sign in to follow this  
raptorstrike

I Know theres a problem (i just dont know how to fix it)

This topic is 4974 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

ok what this function is doing is (wow this is complicated) ok its reading in a text file that has some atributes of the object, then puting it at posistion 50,50 and placing that object in the back of a vector i think the problem is in the enemy constructor but ill post more code then that
void Level::run(int LVL_NUM,char* Master_Enemy_List[])
{  

        Enemy* New_Enemy = new Enemy(Master_Enemy_List[0],50,50,&this->Enemy_Vector);// master list is the .txt files that the constructor reads from
        this->Enemy_Vector.push_back(New_Enemy);
        this->Respawn++;
    return;
};        



Enemy::Enemy(char* File_Name, int x, int y,vector<Enemy*> *V_Enemy)
{
    FileName = File_Name;
    R_Enemy.x = x;
    R_Enemy.y = y;
    ifstream fin;
    this->Name = "";
    fin.open(FileName);
    getline(fin, Name);
    fin >> this->Life;
    getline(fin, Image);
    fin >> this->Weapon_ID; // index to a weapon array;
    fin >> this->Speed;
    fin >> this->ID;//index to enemy array
    fin.close();
    V_Enemy->push_back(this);
};        



//part of source
char* Master_Enemy_Files[] = {"Enemy_One.txt"}; 
//later
I_Enemy = SDL_LoadBMP(Enemy_List[One->Enemy_Vector->ID]);
             TempRectBlit(I_Enemy,screen,One->Enemy_Vector->R_Enemy);
             One->Enemy_Vector->R_Enemy.x -= One->Enemy_Vector->Speed;



lol oops ok the problem is that this image is sapposed to render and move accross the screen briefly (yes thats it for now) and it isnt i ran to debugger and got 2 segmentation faluts but it wont point our were they are and since these are the only 2 functions that i have changed today its gotta be them also when commenting out the run() it runs fine

Share this post


Link to post
Share on other sites
Advertisement
I can almost gaurantee the problem is caused by mixing pointer and array type parameters. Use pointer-types exclusively. You're probably not deleting the new'd object in run.

Share this post


Link to post
Share on other sites
acctuall i think the problem is that i was treating this

const char* Enemy_List[] = {"Enemy.bmp"};

as this

const char* Enemy_List[][50] = ("Enemy.bmp"};

would a vector of const char* do the job?

i want each "blalblablal" to be treated as ONE thing not a whole bunch of chars but i have to use const char* for file names (i cant use strings) so would that suffice??

Note: i put this alot for clarity and if there are external variables with simaler names

[Edited by - raptorstrike on November 8, 2004 9:52:22 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!