converting graphics to tile coords
Okay, so I'm working on a 2d isometric opengl sprite based engine. First off, I use textures quads for sprites (including tiles). Here's some code(it's just an example please don't critique my code) showing how I render tiles.
Now what I need to do is to be able to check which pixel(in opengl coordinates) the mouse if on(which is no problem) and then take this pixel and figure out which tile the mouse is on. So basically I need to be able to convert opengl coordinates to my isometric tile coordinates. Anyone have any idea of how I should go about this?
Code:
for (x = 0; x < MAP_WIDTH; x++)
{
for (y = 0; y < MAP_HEIGHT; y++)
{
// since the tiles are isometric i have to offset them when drawing
// to get them to display properly
offset tile (TILE_PIXEL_WIDTH/2)
offset tile (TILE_PIXEL_HEIGHT/2)
draw_quad(tile_quad);
}
}Now what I need to do is to be able to check which pixel(in opengl coordinates) the mouse if on(which is no problem) and then take this pixel and figure out which tile the mouse is on. So basically I need to be able to convert opengl coordinates to my isometric tile coordinates. Anyone have any idea of how I should go about this?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Converting (x, y) into NESW direction | unknown | 19 | 9,730 |
Nov 2, 2005 09:52 AM Last Post: Zekaric |
|
| Converting Int To String | Nick | 4 | 13,530 |
Jun 2, 2005 02:13 AM Last Post: hangt5 |
|
| How to flip window coords | maaaaark | 3 | 2,714 |
May 4, 2005 02:32 PM Last Post: kelvin |
|
| converting xyz rotation to something else | reubert | 10 | 5,381 |
Mar 5, 2005 07:33 PM Last Post: Puzzler183 |
|
| Converting strings to functions | Joseph Duchesne | 10 | 4,994 |
Feb 23, 2005 11:42 PM Last Post: Skorche |
|

