Isometric Grid - Tiles as objects

Hi!

I’m trying to learn about Isometric projection and so far I understand the concept, but the mathematics I saw are a little confusing. Seems like everybody has it’s own way of doing them: some are complex, some are simple…

I came up with my own way of drawing into a isometric grid, but the real challenge is mapping the mouse coords to the individual cells in the grid.

I never saw this done (don’t know why), but I made every tile on my grid an object with a polygon surrounding it’s boundaries and I think is pretty simple and straightforward, because I only need to check if mouseX & mouseY are inside them.

Don’t know about a full game using this method, but so far it’s fast and reliable.

What do you think about this? Any recommendation?

I’m still trying to learn the “usual” way to do it, anyway…

well i know one way of doing it is to use libgdx
heres an example https://github.com/libgdx/libgdx/blob/d0de5843edd4c9c4903188b203a9a3e098840b12/tests/gdx-tests/src/com/badlogic/gdx/tests/TiledMapAssetManagerTest.java

if your making it from scratch i cant help much with that

I think you answered your own question :).

Making each tile an instance of a class makes sense and it looks like you have a reasonable and workable solution so I would stick with what you have unless some issue (performance, complexity, etc) forces you to change.

If you are still wondering if you have the right approach, it is worth thinking through a couple of scenarios that you plan for your game to see how well your current set up will handle it.

  1. Will the player be able to rotate the board as a whole and/or zoom in and out? If so, do you think your current set up will be able to handle it?
  2. When you have things on the tiles (units, buildings, whatever), will your setup be able to handle that. For instance, if the top of a building overlaps with a title and the player hovers over it, will your setup be able to detect that?

As an aside, I like the idea of the volume of the tile being highlighted as you hover over it (maybe as a colored translucent cube borderless cube).

That’s how X-COM: UFO Defense does it, hehe. Not my idea.

Thanks for the input. It’s too early to tell what you asked, since I’m first trying to master everything I need to do for my game before actually doing it.

About the zoom: with AffineTransform i can easilly zoom in and out and everything keeps in place. I was messing around with it yesterday and it’s awesome. I’ll have to check it out with an actual game running.

I’ll make a similar game as UFO Defense, just for the sake of practice. It’s an awesome game.

There’s no “usual” way. There are just ways that work and don’t work. What’s key is how you separate logic, data and graphics. And two of those three have nothing to do with isometric projections at all.

I just got curious because I didn’t see this simpler approach done in the many tutorials I’ve seen on the internet.