Getting Started
I am new to Java Game Development, and I need some help with a game that I am currently in the process of creating. The game will be fullscreen, it will consist of a board that will be divided into many hexagonal cells. Each cell will contain a terrain texture (water, moutains, desert, etc), and possibly a game piece, like an avatar representing a player. I hava some questions:
1. How should I handle the fullscreen aspect? Either make a window without a title bar and maximize it, or use someother fullscreen API?
2. How do I draw the hexagonal cells? Each cell will have a black outline, and display the given texture.
3. How do I display the textures? Each texture is a .gif file 128 pixels by 128 pixels.
4. How do I overlay the avatar on the cell. I was thinking about using the Glass Pane, but if I use someother 3d API then what do I do.
5. How do I add a zoom in/out factor to the game, where the map scales and displays accordingly.
Any Help would be apprecieated.
[1019 byte] By [
madtown54] at [2007-9-27 22:42:21]

I'm assuming this board of yours will be 2D, I hope. I wouldn't suggest someone new to dive straight into 3D stuff.
> 1. How should I handle the fullscreen aspect? Either
> make a window without a title bar and maximize it, or
> use someother fullscreen API?
Read about the Java Fullscreen API at:
http://java.sun.com/docs/books/tutorial/extra/fullscreen/
Note that this API requires at least JDK1.4. In simple terms, you take any old frame and give it fullscreen properties.
> 2. How do I draw the hexagonal cells? Each cell will
> have a black outline, and display the given texture.
>
> 3. How do I display the textures? Each texture is a
> .gif file 128 pixels by 128 pixels.
This one's a toughie. You'd probably need to use Swing to make custom "cell" components and the Java 2D API to make the hexagonal shape and such. Some Swing components like JLabel have a method called setIcon(), where you can display an image, like your textures. However, if the texture file is rectangular, and cell is hexagonal, you might have trouble with overlap, or maybe not I'm not sure.
For setting up the hexagonal grid, you could probably make a two-dimensional grid container and shove over every 2nd row by half a cell.
> 4. How do I overlay the avatar on the cell. I was
> thinking about using the Glass Pane, but if I use
> someother 3d API then what do I do.
>
> 5. How do I add a zoom in/out factor to the game,
> where the map scales and displays accordingly.
4 and 5 are out of my ballpark. Sorry. :( Though for avatars, you might consider using LayeredPanes instead of GlassPanes.
Frumple
Hi, i'll just add to the last post.
Definitly check out the 2D fullscreen tutorial. You don't want to go to 3D for your first project.
The main idea is you create a frame for the game, and a running thread, in run you update the game, then render it. No need for any other swing or awt components.
Think about a int[][] grid, with the entry at map[x][y] = type of cell.
Make a sprite loader that maps file names to images, and returns cached copys of the images.
When your rendering you draw in the depth order you want, so you'd render the background,environment, then players.
Zooming is harder and depends on your stucture. The easiest way is the call g.setTransform(AffineTransform.getScaleInstance(2.0));
Hope that helps.
Hey, just thought id post this hex patten filler.
Harley.
g.setColor(Color.black);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int cellSize = 40;
int c33 = cellSize /3;
int c50 = cellSize /2;
int c66 = c33 + c33;
for(int i = 0; i<800; i+=cellSize)
{
for(int j = 0; j<600; j+=cellSize)
{
int x = i;
int y =j;
g.drawLine(x +c33, y,x + c66 ,y);
g.drawLine(x + c66,y,x + cellSize,y + c33);
g.drawLine(x + cellSize, y + c33, x+cellSize, y + c66);
g.drawLine(x + cellSize, y + c66, x + c66, y + cellSize);
g.drawLine(x+ c66, y+cellSize, x+c33, y+cellSize);
g.drawLine(x +c33, y+cellSize, x, y +c66);
g.drawLine(x,y +c66,x,y +c33);
g.drawLine(x, y +c33, x + c33, y);
}
}