Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have my isometric world represented by isometric tiles. If I were to allow the player to place buildings on any of the tiles how would I get this funcitonality to work?

I was thinking if I could add a MouseListener to the images?

share|improve this question
1  
You have mentioned you have a mouse listener and an image object but have not told us what environment this is done in so I do not think we can give you an answer you want. –  James Dec 4 '11 at 23:37
    
Oh my mistake, it's being made in Java. I'm using the Diamond approach. –  user1048606 Dec 4 '11 at 23:47
add comment

1 Answer

I would highly recommend not using the MouseListener on the images for one main reason: The graphics should only be a visual representation of what's happening in the game. Using the graphics to control the game creates high coupling between the graphics and the game, which will make it hard to modify or improve later down the road.

I would recommend using math to convert the mouse position to a game position like this article describes: http://www.tonypa.pri.ee/tbw/tut18.html

share|improve this answer
    
I see, I've read about other implementations involving using the matrix inverse to inverse mouse co-ordinates which output the tile's co-ordinates but I'm not entirely sure if I understood the article or not, am I right in this assumption? –  user1048606 Dec 5 '11 at 18:01
    
@user1048606, I'm not very familiar with Matrices myself, but I'm sure there are ways that you can use them to convert from screen-space (the mouse) to game-space. Do a few google searches, and you will surely find an article that describes how to do this using Matrices, it's not an uncommon procedure. To be clear, you can either use matrices, or you can use plain old math, whichever you are more comfortable with. Using a matrix will probably be faster, but if you are unfamiliar with them, the processing speed isn't worth the headache imo. –  John McDonald Dec 5 '11 at 18:20
    
I'm able to get the tile positions now but I'm still unable to highlight tiles as my cursor goes over them and I'm unable to place building on my tiles. –  user1048606 Dec 6 '11 at 1:39
    
@user1048606, you should make a new question for the new issues. Sorry, I can't help any more. –  John McDonald Dec 6 '11 at 17:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.