member func question

Started by
5 comments, last by anandj 15 years, 11 months ago
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
Advertisement
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?
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
Show me the code for Setxy, and the definition of pos's type.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
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
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.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Where is pos being initialized in your code?

This topic is closed to new replies.

Advertisement