Slick Forums

Discuss the Slick 2D Library
It is currently Fri Oct 19, 2018 2:43 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Nov 26, 2012 3:38 pm 
Offline

Joined: Sat Sep 29, 2012 8:13 pm
Posts: 13
Hey guys,

after days of googling and massive headache, I'm forced to ask here^^

My problem is I don't really know how to check if the player has clicked on a isometric tile...
The algorithm should return the map coordinates (such as 0,0;12,3;...)

But the core problem is how to transform the px/py coordinates to mapx/mapy coordinates.

I read this article: http://allefant.com/articles/isometricprojection/

But example calculations gave me completely wrong results.

My actual map: Image

The calculations with the algorithms from allefant were:
tile_x = (pixel_x/(tile_w/2) + pixel_y/(tile_h/2)) / 2
tile_y = (pixel_y/(tile_h/2) - pixel_x/(tile_w/2)) / 2

17,xxx = (637/(64/2) + 230/(32/2)) / 2
4,xxx = (230/(32/2) - 637/(64/2)) / 2

As you can see from my map, the results should be both 0!

This is frustrating as hell-.-

Can you help me?


Top
 Profile  
 
PostPosted: Mon Nov 26, 2012 4:58 pm 
Offline
Regular
User avatar

Joined: Sun Feb 06, 2011 11:59 pm
Posts: 107
Location: USA
Does this help:

http://gamedev.stackexchange.com/questions/30566/how-would-i-translate-screen-coordinates-to-isometric-coordinates

_________________
"When you break the big laws, you do not get freedom; you do not even get anarchy. You get the small laws."
-GK Chesterton


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group