# Slick Forums

Discuss the Slick 2D Library
 It is currently Mon Jan 21, 2019 8:09 pm

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Check if mouse over tile?Posted: Mon Nov 26, 2012 3:38 pm

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.

But example calculations gave me completely wrong results.

My actual map:

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

 Post subject: Re: Check if mouse over tile?Posted: Mon Nov 26, 2012 4:58 pm
 Regular

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

_________________
"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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 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 forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ General    Games / Demos    Help / Discussion    Community Projects    Game Ideas/Design    Slick Competition 2011    Android Slick - LWJGL 2D Game Library    Announcements    Bug Reports / RFE    Extensions    Contribution depot Related Libraries and Tools    Phys2D    Tiled    TWL    Fizzy    Artemis Archive    Resolved Bugs/RFE    Useful Posts