Converting Mouse Coor to Iso Coor
I''m experimenting with and iso engien idea and I''ve come to a little problem. My map is in the form of a 2D array and is plotted as a square map. I want to be able to move my mouse on a tile and place a box around it. At the moment when I click the left mouse button the box just appears wherever I click. Do I need to covert the mouse coors to ido coors? Can someone help me out?
I may be able to help.
I have had a lot of experience with iso and tile based
graphics. I don''t have the code with me now but when I find it I will post it here.
I have had a lot of experience with iso and tile based
graphics. I don''t have the code with me now but when I find it I will post it here.
http://www.crosswinds.net/~druidgames/resist.jpg
Here is the code I use to translate the mouse position to plot tiles. This function is VERY simple and does not work on floating point numbers.
#define TileSizeX 16
#define TileSizeY 16
void MouseToIso(int *x, int *y);
void MouseToIso(int *x, int *y)
{
*x=((*x/TileSizeX)*TileSizeX);
*y=((*y/TileSizeY)*TileSizeY);
return x, y;
}
Call this function like this:
MouseToIso(&x,&y);
I hope this works for you.
#define TileSizeX 16
#define TileSizeY 16
void MouseToIso(int *x, int *y);
void MouseToIso(int *x, int *y)
{
*x=((*x/TileSizeX)*TileSizeX);
*y=((*y/TileSizeY)*TileSizeY);
return x, y;
}
Call this function like this:
MouseToIso(&x,&y);
I hope this works for you.
http://www.crosswinds.net/~druidgames/resist.jpg
Perhaps I am just reading that code wrong, but what exactly does dividing by TileSize and then instantly multiplying by TileSize accomplish?
_-Gizmo-_
Btw, why is the function returning x, y? It shouldn''t return anything at all (since it''s a void function)
=======================================
:: Muzzafarath (Andreas Jonsson)
:: Mad House Software
:: Xtreme Gamerz
:: E-mail address: de@goteborg.mail.telia.com
:: ICQ #64570151
=======================================
Cum catapultae proscriptae erat, tum soli proscript catapultas habebunt - If catapults become illegal, then only illegal people will own catapults.
=======================================
:: Muzzafarath (Andreas Jonsson)
:: Mad House Software
:: Xtreme Gamerz
:: E-mail address: de@goteborg.mail.telia.com
:: ICQ #64570151
=======================================
Cum catapultae proscriptae erat, tum soli proscript catapultas habebunt - If catapults become illegal, then only illegal people will own catapults.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement