Mouse to tile problem

Started by
16 comments, last by cb007sax 21 years, 4 months ago
Taken from my engine, I hope it helps:

void get_world_x_y(){	float x,y,x1,y1,a,t;	x=(float)(mouse_x*9.0f/window_width)-(9.0f/2.0f);	y=(float)((window_height-mouse_y)*6.0f/window_height)-(6.0f/2.0f);	a=(rz)*3.1415926/180;	t=(rx)*3.1415926/180;	y=y/cos(t);	x1=x*cos(a)+y*sin(a);	y1=y*cos(a)-x*sin(a);	scene_mouse_x=-cx+x1;	scene_mouse_y=-cy+y1;} 


Height Map Editor
Advertisement
man this is killing me, i''ve done this for like a week and got nothing, all the stuff you guys have posted have been helpful but i need a good tut. I would like to buy that book but don''t feel like spending money... doesn''t anyone know alot on the subject and want to talk on aim ?
Wait a second.
Is your game 2d or 3d? If it is 2d, what are the angles? (the top/down and left/right angles)

Height Map Editor
2d............................
i don''t want to use angle math though
I''ve submitted an article a while back on using 2d Isometric tiles with a height maped mouse map, and I''m still waiting on a reply about when / if it will be shown.

If you are still needing help drop me an e-mail and I will try and help you out.

The amount of tutorials out there are numerous, and I''ve looked at most of them. I still think that TANSTAAFL''s book describes it best and in the simplest form.



When I find my code in tons of trouble,
Friends and colleages come to me,
Speaking words of wisdom:
"Write in C."
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
quote:Original post by cb007sax
2d............................
i don''t want to use angle math though


Why? It can eb evry helpful, and it''s not even complicated.



Height Map Editor
A nice solution that Civilization 2 uses is a bitmap with various colors for the different parts of an isometric tile. I assume it calculates where the mouse is on the bitmap, finds what color is at that position, and uses that to determine the tile location.

yeah, that is what I am going to use in my game. The game sees an iso tile as a bunch of overlapping rectangles. When you click, it calculates which rectangle you clicked on, then calculates the click coordinates relative to the rectangle. It then compares the relative coordinate on that click to an iso tile in memory, where each section is a different color. Based on the color it can detrmine the tile.

--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved

This topic is closed to new replies.

Advertisement