Page 1 of 1

I Have No Idea Whats Wrong...

Posted: Mon May 04, 2009 11:00 pm
by davidthefat
I know its with the arguments, but I have no Idea how to fix it...

I uploaded it since I dont want to copy paste....


fixed something

Code: Select all

void GameSetUp::SetCoor(int X, int Y, int TempX, int TempY)
{
     x = X;
     y = Y;
     tempX = TempX;
     tempY = TempY;
}

Still the map is still messed up

Re: I Have No Idea Whats Wrong...

Posted: Mon May 04, 2009 11:14 pm
by davidthefat
New File, fixes the moving but not the map, need help on map ;)

Re: I Have No Idea Whats Wrong...

Posted: Tue May 05, 2009 1:24 am
by Kros
Could you specifically outline the code thats "broken" and what your specific problem is? Most of us really dislike having to download source, get the libraries, compile/build, then figure out whats wrong (can vary depending on what your view of 'wrong' is).

Also, for future reference: http://www.pastebin.com is a fantastic site for collaborative debugging.

Thanks.

Re: I Have No Idea Whats Wrong...

Posted: Tue May 05, 2009 2:30 am
by programmerinprogress
One way you might consider when writing argument names which are almost identical to some members in your class, is using the this keyword and the arrow operator (->) to make things clearer (it also means you don't have to worry about running out of relevant keywords)

for example, you would implement your first chunk of code like this:

Code: Select all

void GameSetUp::SetCoor(int x, int y, int Tempx, int Tempy)
{
     this->x = x;
     this->y = y;
     this->tempx = Tempy;
     this->tempx = Tempy;
}
PS: I didn't look at the rest of your code, I really don't have the time at the moment, but I hope you solve the problem in a stress-free and timely manner.

Maybe you should explain exactly what's wrong, if you need anymore help.

Re: I Have No Idea Whats Wrong...

Posted: Tue May 05, 2009 5:33 pm
by davidthefat
I think the problem is with the loading of the map arrays or the actual drawing of it...

Re: I Have No Idea Whats Wrong...

Posted: Tue Jun 02, 2009 6:46 pm
by resatti
make sure that all the variables are DECLARED

Re: I Have No Idea Whats Wrong...

Posted: Tue Jun 02, 2009 7:12 pm
by davidthefat
resatti wrote:make sure that all the variables are DECLARED
Obviously they are :roll:

Re: I Have No Idea Whats Wrong...

Posted: Wed Jun 03, 2009 9:05 am
by Scoody
You can't copy an array like this:

Code: Select all

     
  map[24][32] = m[24][32];
  objMap[24][32] = o[24][32];
Arrays start at 0, so what you're doing here is assigning the value that happens to reside somewhere outside the array m to the array map; or actually you're not assigning it to the map array, it's outside that one too.

You should read more on arrays and understanding them, it will make this task much easier.

Re: I Have No Idea Whats Wrong...

Posted: Wed Jun 03, 2009 9:15 am
by programmerinprogress
Scoody wrote:You can't copy an array like this:

Code: Select all

     
  map[24][32] = m[24][32];
  objMap[24][32] = o[24][32];
Arrays start at 0, so what you're doing here is assigning the value that happens to reside somewhere outside the array m to the array map; or actually you're not assigning it to the map array, it's outside that one too.

You should read more on arrays and understanding them, it will make this task much easier.
also, you can't just assign an array to an array in c++ AFAIK, you initialise an array by either including braces and the list of values you wish to initialise the array with, or you could use some iteration to assign those values to the correct corresponding arrays, for example, for a 2 dimensional array, some nested for loops will usually suffice.

Code: Select all

for(int i = 0; i < 24; i++)
{
   for(int j = 0; j < 32; j++)
   {
         map[i][j]  = m[i][j]
   } 
}

// just as a side note, I would recommend using constants instead of 24 and 32 
// you'll end up having inconsitent numbers which could lead to bugs if you 
// don't have identifiers that you only have to change once

Re: I Have No Idea Whats Wrong...

Posted: Wed Jun 03, 2009 8:27 pm
by short

Code: Select all

void GameSetUp::SetCoor(int x, int y, int Tempx, int Tempy)
{
     this->x = x;
     this->y = y;
     this->tempx = Tempy;
     this->tempx = Tempy;
}
If this function is inside a class that you are instantiating then it should work.

edit: are you instantiating a new GameSetUp object? If you are, then the above should be your solution.