|
GTGE API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.golden.gamedev.object.Background
com.golden.gamedev.object.background.abstraction.AbstractIsometricBackground
com.golden.gamedev.object.background.IsometricBackground
public class IsometricBackground
The basic isometric background, creates a one layer isometric background.
IsometricBackground takes up two parameter, the first one is a
two dimensional array of integer (int[][] tiles) that makes up the background
tiling, and the second one is the tiling image array
(BufferedImage[] tileImages).
This isometric background is the basic subclass of
AbstractIsometricBackground that overrides renderTile
method to draw one layer isometric background :
public void render(Graphics2D g, int tileX, int tileY, int x, int y) {
// tiles is the two dimensional background tiling
int tile = tiles[tileX][tileY];
if (tile >= 0) {
// tileImages is the tiling images
g.drawImage(tileImages[tile], x, y, null);
}
}
To create multiple layer, simply subclass AbstractIsometricBackground
and override the renderTile method to render the tile multiple
times. Isometric background usage example :
IsometricBackground background;
BufferedImage[] tileImages;
int[][] tiles = new int[40][30]; // 40 x 30 tiling
// fill tiles with random value
for (int i=0;i < tiles.length;i++)
for (int j=0;j < tiles[0].length;j++)
tiles[i][j] = getRandom(0, tileImages.length-1);
// create the background
background = new IsometricBackground(tileImages, tiles);
AbstractIsometricBackground,
Serialized Form| Field Summary |
|---|
| Fields inherited from class com.golden.gamedev.object.Background |
|---|
screen, x, y |
| Constructor Summary | |
|---|---|
IsometricBackground(BufferedImage[] tileImages,
int[][] tiles)
Creates new IsometricBackground with specified tile images
and array of tiles. |
|
IsometricBackground(BufferedImage[] tileImages,
int[][] tiles,
int offsetTileHeight,
int startY)
Creates new IsometricBackground with specified tile images,
array of tiles, offset of tile height, and starting y coordinate. |
|
IsometricBackground(BufferedImage[] tileImages,
int horiz,
int vert)
Creates new IsometricBackground with specified tile images
as big as horiz and vert tiles. |
|
| Method Summary | |
|---|---|
BufferedImage[] |
getTileImages()
Return the isometric background tile images. |
int[][] |
getTiles()
Returns the isometric background tiling. |
void |
renderTile(Graphics2D g,
int tileX,
int tileY,
int x,
int y)
Renders tile at tileX, tileY position to
specified x, y coordinate. |
void |
setSize(int horiz,
int vert)
Sets the size of this background. |
void |
setTileImages(BufferedImage[] tileImages,
int offsetTileHeight)
Sets the isometric background tile images. |
void |
setTiles(int[][] tiles)
Sets the isometric background tiling. |
| Methods inherited from class com.golden.gamedev.object.background.abstraction.AbstractIsometricBackground |
|---|
getCoordinateAt, getOffsetTileHeight, getStartY, getTileAt, getTileHeight, getTileWidth, getTileX, getTileY, getTotalHorizontalTiles, getTotalVerticalTiles, render, setLocation, setStartY, setTileLocation, setTileSize |
| Methods inherited from class com.golden.gamedev.object.Background |
|---|
getClip, getDefaultBackground, getHeight, getWidth, getX, getY, move, render, setClip, setClip, setToCenter, setToCenter, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IsometricBackground(BufferedImage[] tileImages,
int[][] tiles,
int offsetTileHeight,
int startY)
IsometricBackground with specified tile images,
array of tiles, offset of tile height, and starting y coordinate. The array of tiles that makes up the isometric background tiling, tiles[0][0] = 2 means the tileImages[2] will be drawn on tile 0, 0 coordinate on the map.
The offsetTileHeight is used to determine the tile image
base tile height, for example the real height of the tile image is 128
but the base height of the tile image is 32, therefore set the
offsetTileHeight to 96 (128-32).
The startY is where the isometric background y coordinate is
starting to render, set this startY value greater than zero
if this background need to be drawn down a bit.
tileImages - an array of images for the tiletiles - a two dimensional array that makes up the backgroundoffsetTileHeight - the tile height offset from the base tile heightstartY - starting y coordinate to draw this background
public IsometricBackground(BufferedImage[] tileImages,
int[][] tiles)
IsometricBackground with specified tile images
and array of tiles. The array of tiles that makes up the isometric background tiling, tiles[0][0] = 2 means the tileImages[2] will be drawn on tile 0, 0 coordinate on the map.
tileImages - an array of images for the tiletiles - a two dimensional array that makes up the background
public IsometricBackground(BufferedImage[] tileImages,
int horiz,
int vert)
IsometricBackground with specified tile images
as big as horiz and vert tiles. Generates isometric tile background with tile as big as horiz and vert (tiles = new int[horiz][vert]) and using the first image of the tile images (tileImages[0]) for all the tiles.
tileImages - an array of images for the tilehoriz - total horizontal tilesvert - total vertical tiles| Method Detail |
|---|
public void renderTile(Graphics2D g,
int tileX,
int tileY,
int x,
int y)
AbstractIsometricBackgroundtileX, tileY position to
specified x, y coordinate.
renderTile in class AbstractIsometricBackgroundpublic BufferedImage[] getTileImages()
public void setTileImages(BufferedImage[] tileImages,
int offsetTileHeight)
public int[][] getTiles()
public void setTiles(int[][] tiles)
This array of tiles that makes up the background, tiles[0][0] = 2 means the tileImages[2] will be drawn on tile 0, 0 coordinate on the map.
setTileImages(BufferedImage[], int)
public void setSize(int horiz,
int vert)
Background
setSize in class AbstractIsometricBackground
|
GTGE API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||