|
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
public abstract class AbstractIsometricBackground
The base abstract class to create isometric background, the subclass need to perform the background tile rendering.
Field Summary |
---|
Fields inherited from class com.golden.gamedev.object.Background |
---|
screen, x, y |
Constructor Summary | |
---|---|
AbstractIsometricBackground(int horiz,
int vert,
int tileWidth,
int tileHeight)
Creates new AbstractIsometricBackground as big as
horiz , vert tiles, where each tile is as big as
tileWidth , tileHeight . |
|
AbstractIsometricBackground(int horiz,
int vert,
int tileWidth,
int tileHeight,
int offsetTileHeight,
int startY)
Creates new AbstractIsometricBackground as big as
horiz , vert tiles, where each tile is as big as
tileWidth , tileHeight with specified tile
height offset, and starting y coordinate. |
Method Summary | |
---|---|
Point |
getCoordinateAt(int tileX,
int tileY)
Returns screen coordinate of specified tile position. |
int |
getOffsetTileHeight()
Returns the tile height offset from the base tile height. |
int |
getStartY()
Returns starting y coordinate where the isometric background start rendered. |
Point |
getTileAt(double screenX,
double screenY)
Returns iso tile position of specified coordinate or null if the coordinate is out of background viewport/boundary. |
int |
getTileHeight()
Returns the base height of the iso tile. |
int |
getTileWidth()
Returns the width of the iso tile. |
int |
getTileX()
Returns current tile-x position. |
int |
getTileY()
Returns current tile-y position. |
int |
getTotalHorizontalTiles()
Returns background total horizontal tiles. |
int |
getTotalVerticalTiles()
Returns background total vertical tiles. |
void |
render(Graphics2D g,
int xbg,
int ybg,
int x,
int y,
int w,
int h)
Renders background from specified position and clipping area to specified graphics context. |
abstract void |
renderTile(Graphics2D g,
int tileX,
int tileY,
int x,
int y)
Renders tile at tileX , tileY position to
specified x , y coordinate. |
void |
setLocation(double xb,
double yb)
Sets background location to specified coordinate. |
void |
setSize(int horiz,
int vert)
Sets the size of this background. |
void |
setStartY(int startY)
Sets starting y coordinate where the isometric background start rendered. |
void |
setTileLocation(int xs,
int ys)
Sets the background location to specified tile. |
protected void |
setTileSize(int tileWidth,
int tileHeight,
int offsetTileHeight)
Sets the size of the iso tile. |
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 AbstractIsometricBackground(int horiz, int vert, int tileWidth, int tileHeight, int offsetTileHeight, int startY)
AbstractIsometricBackground
as big as
horiz
, vert
tiles, where each tile is as big as
tileWidth
, tileHeight
with specified tile
height offset, and starting y coordinate.
horiz
- total horizontal tilesvert
- total vertical tilestileWidth
- the width of the iso tiletileHeight
- the height of the iso tileoffsetTileHeight
- the tile height offset from the base tile heightstartY
- starting y coordinate to draw this backgroundpublic AbstractIsometricBackground(int horiz, int vert, int tileWidth, int tileHeight)
AbstractIsometricBackground
as big as
horiz
, vert
tiles, where each tile is as big as
tileWidth
, tileHeight
.
horiz
- total horizontal tilesvert
- total vertical tilestileWidth
- the width of the iso tiletileHeight
- the height of the iso tileMethod Detail |
---|
public void render(Graphics2D g, int xbg, int ybg, int x, int y, int w, int h)
Background
This method to simplify background subclass rendering, the subclass only need to render the background from specified x, y coordinate with specified clipping area.
For example:
Background backgr; Graphics2D g; backgr.render(g, 100, 100, 5, 10, 100, 200);Means the background must render itself from background coordinate 100, 100 to specified graphics context, starting from 5, 10 screen pixel as large as 100 x 200 dimension.
render
in class Background
g
- graphics contextxbg
- background x-coordinateybg
- background y-coordinatex
- screen start x clippingy
- screen start y clippingw
- clipping widthh
- clipping heightpublic abstract void renderTile(Graphics2D g, int tileX, int tileY, int x, int y)
tileX
, tileY
position to
specified x
, y
coordinate.
public void setLocation(double xb, double yb)
Background
setLocation
in class Background
xb
- the x
coordinate of the backgroundyb
- the y
coordinate of the backgroundpublic void setTileLocation(int xs, int ys)
public int getTileX()
public int getTileY()
public Point getTileAt(double screenX, double screenY)
public class YourGame extends Game { AbstractTileBackground bg; public void render(Graphics2D g) { Point tileAt = bg.getTileAt(getMouseX(), getMouseY()); if (tileAt != null) { // mouse cursor is in background area // draw pointed tile // convert tile to coordinate Point coordAt = bg.getCoordinateAt(tileAt.x, tileAt.y); g.setColor(Color.WHITE); g.drawRect(coordAt.x - (int) bg.getX() + bg.getClip().x, coordAt.y - (int) bg.getY() + bg.getClip().y, bg.getTileWidth(), bg.getTileHeight()); } } }
public Point getCoordinateAt(int tileX, int tileY)
getTileAt(double, double)
to get tile
coordinate at specified coordinate.
public int getTileWidth()
public int getTileHeight()
This is the base height of the isometric tile, the actual image tile is
getTileHeight()
+ getOffsetTileHeight()
.
getOffsetTileHeight()
public int getOffsetTileHeight()
protected void setTileSize(int tileWidth, int tileHeight, int offsetTileHeight)
tileWidth
- the width of the iso tiletileHeight
- the height of the iso tileoffsetTileHeight
- the tile height offset from the base tile heightpublic int getStartY()
public void setStartY(int startY)
public int getTotalHorizontalTiles()
public int getTotalVerticalTiles()
public void setSize(int horiz, int vert)
Background
setSize
in class Background
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |