Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  isometric problem  (Read 1963 times)
0 Members and 1 Guest are viewing this topic.
Offline kemalenver

Senior Newbie

null pointer exception

« Posted 2003-03-01 12:36:03 »

   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:

Click to Play

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.  Huh
Offline cfmdobbie

Senior Devvie

Medals: 1

Who, me?

« Reply #1 - Posted 2003-03-01 16:33:07 »

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? ;-)

Hellomynameis Charlie Dobbie.
Offline kemalenver

Senior Newbie

null pointer exception

« Reply #2 - Posted 2003-03-01 17:33:22 »

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);
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cfmdobbie

Senior Devvie

Medals: 1

Who, me?

« Reply #3 - Posted 2003-03-02 20:53:20 »

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:

There's some good readin' at GameDev! Grin

Hellomynameis Charlie Dobbie.
Offline kemalenver

Senior Newbie

null pointer exception

« Reply #4 - Posted 2003-03-02 21:39:39 »

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!  Grin  I just need to draw some graphics!  Any ideas where I can get some free ready made  ones  Wink
Offline cfmdobbie

Senior Devvie

Medals: 1

Who, me?

« Reply #5 - Posted 2003-03-02 23:07:22 »

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... Tongue

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

You could try looking for leads from - 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 - 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?

Hellomynameis Charlie Dobbie.
Offline kemalenver

Senior Newbie

null pointer exception

« Reply #6 - Posted 2003-03-07 13:39:00 »

Smiley 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  Embarrassed  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!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (26 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (26 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39

Jesse (39 views)
2015-07-22 03:10:36
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!