Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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 1605 times)
0 Members and 1 Guest are viewing this topic.
Offline kemalenver

Senior Newbie




null pointer exception


« Posted 2003-03-01 13: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.  Huh
Offline cfmdobbie

Senior Member




Who, me?


« Reply #1 - Posted 2003-03-01 17: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 18: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<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 Member




Who, me?


« Reply #3 - Posted 2003-03-02 21: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! Grin

Hellomynameis Charlie Dobbie.
Offline kemalenver

Senior Newbie




null pointer exception


« Reply #4 - Posted 2003-03-02 22: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 Member




Who, me?


« Reply #5 - Posted 2003-03-03 00: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 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.
Offline kemalenver

Senior Newbie




null pointer exception


« Reply #6 - Posted 2003-03-07 14: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (75 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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
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!