# member func question

## Recommended Posts

Ok, so i have this class, well, a struct rather, that has a function that Is causing me grief. Para-coded to leave out a bunch of bounds checking that I have deduced to not be the culprit.
void _entity::Warp(int x, int y)
{
pos.Setxy(x, y);
}

Where as pos is a coord struct with an x, a y, whiche are set with Setxy(); Setxy works, as Ive used it to set other things before, but when used within Warp() it doesnt seem to work, and I can seem to figure out why

##### Share on other sites
You'll need to be a bit more specific than "it doesn't seem to work". What do you expect to happen, what do you observe to happen, and what steps have you taken to debug why the two results are different?

##### Share on other sites
Well, it doesnt set the variables. I havent gotten the debugger to work on my laptop yet, but Ive created a series of file outputs to check variables before and after every set leading up to warp being called, and afterwards. the variables before and after are identical. and in the game itself, the player entity does not relocate from 1,1 (where function is called) to 34, 34 (which is the exspected new location). The text output walks through the thingy, shows everything is getting called, but does not move the player, he simply stays still, and further keyboard input moves him from the origonal location as if the warp did not happen.

hmm... well, maybe this might help

void Setxy(int xx, int yy) {x = xx; y = yy;}

that is the method, x and y being the other members, both ints

##### Share on other sites
Show me the code for Setxy, and the definition of pos's type.

##### Share on other sites
struct _coord
{
_coord() {};
_coord(int xx, int yy) : x(xx), y(yy) {};
~_coord() {};

int x;
int y;

void Setxy( int xx, int yy ) {x = xx; y = yy;}

}CORD, *LPCORD;

there she is

##### Share on other sites
I can't see where there could be a problem. Are you sure the proper parameters are being passed to _entity::Warp in the first place, and are you sure that pos.x and pos.y are being used the way you intended them?

From the looks of it, I can't believe that these few bits are the actual problem.

##### Share on other sites
Where is pos being initialized in your code?

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627657
• Total Posts
2978471

• 10
• 12
• 22
• 13
• 33