Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
I got a move packet. I'm interested in the X and Y position of the player. Is there something that I have to divide them by to get it in terms of blocks on the map? The Y axis is not long enough and the X axis is too short (relative to the world.)
I'm trying to overlay them on a map, and I have to stretch the coordinates, and it's not making sense to me.
Offline
int x = m.GetInt((1) / 16);
int y =m.GetInt((2) / 16);
Haven't done movement in a while, but isn't that the same thing?
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
int x = m.GetInt((1) / 16);
int y =m.GetInt((2) / 16);
I tried that before and it didnt work :/
Fix:
int x = (int)(m.GetInt(1)) / 16;
int y = (int)(m.GetInt(2)) / 16;
Offline
xfrogman43 wrote:int x = m.GetInt((1) / 16);
int y =m.GetInt((2) / 16);I tried that before and it didnt work :/
Fix:
int x = (int)(m.GetInt(1)) / 16; int y = (int)(m.GetInt(2)) / 16;
The values at 1 & 2 are doubles.
You have to use GetDouble and round them since they can be something like 2160.349298398 and that is not an int. unless you round it.
And dividing it by 16 gives you the block coords they're on.
The reason it's multiplied by 16 is probs the size of the smiley. since the location needs to be accurate.
Offline
Unless you want it to give you int values for the loc, then the code you posted should work except you don't need the "(double)" as 16 counts as a double, too.
Offline
To fill up DarkDragon4900's statement:
you don't need the "(double)" as 16 counts as a double, too.
Every integer can be typecasted into a double, and will be done automatically if it has to be done.
Officially 16 counts as an integer, but the compiler converts it into a double, as it notices a double is required.
And a bit quicker way (in my opinion) to covert 16 into a double would be by declaring it as such '16.0'. (When you're have an int variable you indeed would have to use '(double)[variable]')
Offline
Actually, what you should do is convert them to int first, then divide with 16.
Because dividing a double with decimals would have bad consequences.
It would return offset positions. Compare.
shh i have returned
Offline
To fill up DarkDragon4900's statement:
DarkDragon4900 wrote:you don't need the "(double)" as 16 counts as a double, too.
Every integer can be typecasted into a double, and will be done automatically if it has to be done.
Officially 16 counts as an integer, but the compiler converts it into a double, as it notices a double is required.
And a bit quicker way (in my opinion) to covert 16 into a double would be by declaring it as such '16.0'. (When you're have an int variable you indeed would have to use '(double)[variable]')
I added the
, too
to indicate that it isn't a double by default :p
Actually, what you should do is convert them to int first, then divide with 16.
Because dividing a double with decimals would have bad consequences.
It would return offset positions. Compare.
I guess i'd agree with this.
Offline
[ Started around 1732490374.7438 - Generated in 0.093 seconds, 12 queries executed - Memory usage: 1.54 MiB (Peak: 1.71 MiB) ]