isometric problem

Hi,
I’m writing a simulation and I’d like to show the results on an isometric grid. I have so far managed to get some tiles to tesselate so it looks ok, the only problem I have is that I need to work out the rectangle
dimensions that bound my grid (as shown here:

http://www.kemalenver.f2s.com/iso.gif

The reason I need these dimensions is so that I can create a panel and an image that will fit the grid exactly. You can see what I mean from the link. I’ve tried various types of trigonometry tricks but I’m not doing it properly I guess! Any ideas / suggsetions as to how to do it would be VERY appreciated. Thanks for your time. ???

No trig required. You have tiles of height 38 and width 76. Given that you have x tiles in the NE direction and y tiles in the SE direction:

“Core” of grid (largest contained rhombus) is (min(x,y)*min(x,y)) squares in size, hence considering the diagonals gives us (min(x,y)*38) in height and (min(x,y)*76) in width.

Every extra line of squares (beyond the “core”) will add both to width and height of the bounding box: (76/2) to the width and (38/2) to the height.

If (x < y) then the grid has more squares to be considered on the SE edge. If (y > x) then they’re on the NE edge. This doesn’t affect the size of the box, but will affect the positioning of the grid inside the box!

All in all:

Bounding box width = ((min(x,y)*76) + (((max(x,y)-min(x,y))*76/2))

Bounding box height = ((min(x,y)*38) + (((max(x,y)-min(x,y))*38/2))

How’s about that then, eh? :wink:

Hi,
Thanks for your reply. I’ll give that a go now. While on this subject, is there a nice way of converting the mouse position into a ‘square position’? I’m using the following code to position the squares when they are drawn (using a square dimensioned grid at moment i.e. x=10 y=10 - makes it easy to work out panel size), but I’m having problems mapping coordinates back:


for(int x = 0; x<gridX; x++)
  for(int y = 0; y<gridY; y++)
    g.drawImage(ImageLibrary.ISO_TILE, (((x-y)*38)+(xsize/2))-38, (x+y)*19, null);

Hrm, good one. It’s probably not too hard - just draw a grid on some paper, and with what you know about how your coordinate system works (where the origin is, what insets exist etc) look at what’s common between all squares of a certain rank.

It’s probably something to do with working out how far the mouse is from the top edge (x = 0) of the grid, along the y gridlines, then integer dividing that number by the length of the diagonal edge of a grid square. Then do the same in the other direction to get the other coordinate. Something like that?

You probably want to read through a few GameDev articles - they have a section on isometric programming in the reference area:

http://www.gamedev.net/reference/list.asp?categoryid=44

There’s some good readin’ at GameDev! ;D

hey cheers for the help. I managed to get the stuff to map eventually. Seems to be working ok. I’ve got a nice little engine going now! ;D I just need to draw some graphics! Any ideas where I can get some free ready made ones :wink:

Hrm, free graphics are in pitifully short supply on the Internet! For some reason artists don’t have as much of a community spirit as programmers… :stuck_out_tongue:

The famous Ari Feldman library doesn’t have any isometric tiles yet, unfortunately.

You could try looking for leads from http://www.isometrix.org/ - I just found it from a Google search and it looks like it should have a few good links. It’s also got a section on math relating to isometric engines, which may be of use to you!

If you want to try creating some art yourself, you could do a lot worse than looking at http://www.zoggles.co.uk/ - an site by an excellent pixel artist who specialises in isometric perspectives. He has written a good number of tutorials and hosts a lot more. There’s some fantastic bits of art in there.

Anyone know of any good, free isometric tile sets?

:slight_smile: hi and thanks for the info. I managed to get a basic isometric engine going, but I’ve given up on it for the mo and gone back to a top down view! I was spending too long on making the simulation look nice rather than getting it done! I only got a month left to finish it :-[ Hopefully after its over I’ll get the chance to write a nice little game for fun and I can use the iso engine i wrote!