I’ve recently become obsessed with isometric pixel art after reading the post on the Java2D board. I’d like to create a game with my newfound talents but I don’t know how to optimize the output to the screen. I want to be able to cut off all tiles not showing on the screen so that it draws much faster. To do this, I would need to represent the tiles in an array and then… what? I don’t know. ???
Assume you have the tiles in a 2d array like:
MapTile[][] aaMapTile;
Then store the x and y coordinates of the top left tile currently visible. Figure out how many tiles fit onto the screen, and just draw the tiles from (x, y) to (x + tile width of screen, y + tile height of screen). Since isometric tiles sort of criss cross, you’ll actually have to draw an extra row/column of tiles in each direction, but that’s an insignificant amount of drawing compared to drawing the whole map. If I get stuck drawing a half-tile, I just draw the whole thing. When you start drawing half of a tile, you can encounter all sorts of weird bugs. It’s not worth the headache since the drawImage methods with clip to the edge of the drawing area anyways.
Really, it’s not all that different from non-isometric tiles unless there’s something about your question that I don’t understand.
I can’t believe I didn’t realize that! I was trying to store all of the tiles in a wierd way, with the x and y aligned to the isometric lines. (See picture.)
So what you’re saying is to store them just like a regular tile game but shift every other tile over half a tile? :o That’s brilliant and really simple. Thanks for making me wake up and smell the coffee.
I did Java code for a basic isometric scroller way back when fullscreen was new, its floating around here somewhere in a file called Scroller.jar.
I based it on the ONLY good book I know of about Isometric game programming, TANSTAAFL’s Isometric Game Programming with DirectX 7.0
Basically, I would shift every tile with an odd x-coordinate down by half a tile. You could do it with even x-coordinates or even/odd y-coordinates. It should be about the same.
I bought the book Jeff mentioned, but I’m reading some design books before I read it. (In the project I’m working on now, I’ve become aware that my design abilities are severely deficient.) Anyways, I bought it for $1.93 plus shipping on Amazon.com. So you can buy the book with ruining your budget.
I don’t know of any alternative book. Killer Game Programming in Java has one chapter that involves isometric programming, but half of the chapter’s actually about pathfinding. Go with “Isometric Game Programming with DirectX 7.0”. Even though I haven’t read it yet, Jeff (and others) reccomend it.
Killer Game Programming in Java is a good book - it’s just about the basics, not about isometric programming.
Thank you all so much for putting up with me and my dumb :-[ questions. I appreciate it a lot.
Another issue I’ve been having (among others) is the best file format to store my pics in. I normally use GIF but I desperately need more colors. The only thing is that I also need the transparency. For image software, I have Paint, ArcSoft PhotoStudio and Microsoft PictureIt! Premium 10. I think PNG saves as transparent but not in PhotoStudio.
What I currently have going is an algo that reads in the file using new ImageIcon(“tiles.gif”).getImage(), uses PixelGrabber to take all of the pixels into an array, replaces all of a specified color with transparent black, then rewrites the data into a BufferedImage. Is there anything faster out there?
Then there’s the frame rate issue. For some reason I’m pushing the limit at about 10 fps. I’m just using standard full screen API (GraphicsDevice.setFullScreenFrame()) and the background that it copies the pictures onto is a rectangle filled with a GradientPaint. It’s double-buffered. I think I might be able to help it out a bit by buying a new computer, but it still burns a lot that it goes that slow. Is there anything I can do other than separate graphics, logic etc. on threads?
Use png, save them as full ARGB. (read the photoshop manual on how to do that - it certainly can; as our artists @ work manage it!)
Load them in using ImageIO.read(…), and then copy them into a compatibleImage with BITMASK transparency. (AlphaComposite.SRC)
Alternatively, if you can find a use for full alpha (and you are using Java1.5+) you can leave them as full alpha, and just use the images returned from ImageIO.read(…).