Advertisement

question (coordinate of map etc)

Started by June 05, 2001 12:11 PM
4 comments, last by ReDair 23 years, 8 months ago
hi pplez, have questions here hope sumone can help mi. i basically understands how to draw isometric map onto the screen, but then..i was tinkin..lets say i have a very large map [1000x1000tiles x 32x16pixel] ..and my mouse points to screenpixel (200 , 200) on a 800 x 600 screen, how do i determine whats the xy map coordinate of the whole map am i pointing at ? can someone pls give me some advice ? i've read sum articles but i dun realli understand. thanx alot Edited by - ReDair on June 5, 2001 11:17:34 PM
What you have to do is add the top left hand co-ordinate of the map onto your mouse co-ordinates. Its that simple. It should go
something like this.

x = mousex + mapx;
y = mousey + mapy;
Advertisement
can u pls explain more elaborately . thanx alot.my whole map is shaped like a diamond.
quote:
Original post by ReDair

can u pls explain more elaborately . thanx alot.my whole map is shaped like a diamond.


my whole map is shaped like a diamond. can i draw the map diagonaly down as folowing the map coordinate or will it be better to do it left to right ? any advice ?
thanx
You have to have some kind of viewport x/y positions for map viewport. Like, ur map starts at 0,0 and your viewport is size 800x600 right?
So, your mouse coord in tiles will be:
xtile=(getmousex+viewportx)/sizeoftilex;
ytile=(getmousey+viewporty)/sizeoftiley;

So, u can get ur tile if ur map is like map[1000][1000], so to access tile ove which ur mouse is over is map[xtile][ytile]
Tans has a really good article in the GameDev forums about mapping the mouse coordinates to a map coordinate. I highly recommend reading that article.





Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.



Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.

Currently working on Rise of Praxis MUD: http://www.riseofpraxis.net/

This topic is closed to new replies.

Advertisement