Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (570) Games in Android Showcase (154) games submitted by our members Games in WIP (619) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 isometric problem  (Read 1870 times) 0 Members and 1 Guest are viewing this topic.
kemalenver

Senior Newbie

null pointer exception

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

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:

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

Senior Newbie

null pointer exception

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

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:

 1  2  3 `for(int x = 0; x
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:

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

There's some good readin' at GameDev!

Hellomynameis Charlie Dobbie.
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!    I just need to draw some graphics!  Any ideas where I can get some free ready made  ones
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...

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?

Hellomynameis Charlie Dobbie.
kemalenver

Senior Newbie

null pointer exception

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

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!
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Riven (24 views) 2015-04-16 10:48:47 Duke0200 (37 views) 2015-04-16 01:59:01 Fairy Tailz (28 views) 2015-04-14 20:13:12 Riven (30 views) 2015-04-12 21:36:37 bus hotdog (47 views) 2015-04-10 02:39:32 CopyableCougar4 (50 views) 2015-04-10 00:51:04 BurntPizza (49 views) 2015-04-06 22:06:58 ags1 (52 views) 2015-04-02 10:58:48 Riven (50 views) 2015-04-01 18:27:05 ags1 (68 views) 2015-03-31 10:55:12
 BurntPizza 24x theagentd 21x wessles 15x Rayvolution 12x kingroka123 11x 65K 11x alwex 10x KevinWorkman 9x kevglass 8x ra4king 8x phu004 8x Ecumene 7x chrislo27 7x Roquen 7x Hanksha 7x Olo 7x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 java-gaming.org 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‑gaming.org