Package com.starpoints.painter
Class Painter2DArena
- java.lang.Object
-
- com.starpoints.painter.PainterBase
-
- com.starpoints.painter.Painter2DArena
-
- All Implemented Interfaces:
Painter
- Direct Known Subclasses:
PainterFieldEditor
public class Painter2DArena extends PainterBase
Painter for 2D game.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]blobsstatic intEFFECT_BUBBLESConstant for painting bubble energy fx.static intEFFECT_DOTSConstant for painting dot energy fx.static intENERGYFX_X_RADIUSx Radius for regeneration fx.static intENERGYFX_Y_RADIUSy Radius for regeneration fx.static intFIELD_MAX_HEIGHTMaximum supported field height.static intFIELD_MAX_WIDHTMaximum supported field width.protected static java.util.Hashtable<java.lang.String,java.lang.String>fogImagesStatic hashtable for fog image storage.protected static java.util.Hashtable<java.lang.String,java.lang.String>heatImagesStatic hashtable for heat image storage.protected java.lang.Stringhorizontalstatic intHOVER_X_FACTx factor for hover fx.static intHOVER_Y_FACTy factor for hover fx.static intITEM_ON_FIGURE_X_SIDEFactor for calculating rocket fx on figure.static intITEM_ON_FIGURE_Y_SIDEFactor for calculating rocket fx on figure.protected static java.util.Hashtable<java.lang.String,java.lang.String>itemImagesStatic hashtable for item image storage.static intOFFSET_LEFTx Offset for the leftmost point image.static intOFFSET_TOPx Offset for the topmost point image.protected PainterFactorypainterFactoryThe PainterFactory.static intPOINT_RADIUS_XRadius for point target fx.static intPOINT_RADIUS_YRadius for point target fx.protected static java.util.Hashtable<java.lang.Integer,java.lang.String>pointImagesStatic hashtable for point image storage.static intROCKET_PAINT_HEIGHTFactor for painting rocket fx on figure.static intROCKET_PAINT_WIDTHFactor for painting rocket fx on figure.static intTEXT_OFFSET_Xx Offset for text paintingstatic intTEXT_OFFSET_Yy Offset for text paintingprotected java.lang.Stringverticalstatic intX_FACTWidth of one point.protected int[]xpPoint x positions.static intY_FACTHeight of one point.protected int[]ypPoint y positions.-
Fields inherited from class com.starpoints.painter.PainterBase
area, areas, bigFont, controller, gameInfo, medFont, mouseArea, offset, oldMouseArea, options, smallFont, state, verysmallFont, xfactor, yfactor
-
-
Constructor Summary
Constructors Constructor Description Painter2DArena(PainterFactory painterFactory)Creates a new painter for a 2D Arena.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyGraphInfo(LevelState levelState)Calculates new graphic coordinates after resize events.protected static voiddrawPointExplosion(Graphics g, PointState pointState, int animationIndex, int xCenter, int yCenter)Performs explosion routine when painting the point.protected voiddrawPointHeating(Graphics g, PointState pointState, GameState state, int xCenter, int yCenter)Paints a heating effect.intgetBaseHeight()Gets the base height of this painter.intgetBaseWidth()Gets the base width of this painter.protected FieldStategetField()Gets the field to display.static java.lang.StringgetFogImage(FogState f)Gets the fogs image to the image with the name specified by getImageName().static java.lang.StringgetItemImage(java.lang.String imageName)Gets the items image filename for the image with the name specified by getImageName().PointgetNearestPoint(int x, int y)Gets the nearest point for the given screen coordinates.PointgetNearestPoint(Field f, int x, int y)Gets the nearest point for the given screen coordinates.PointgetNearestPoint(Field f, int x, int y, Rectangle area)/** Gets the nearest point for the given screen coordinates.PointStategetNearestPointState(FieldState f, int x, int y)Gets the nearest PointState for the given screen coordinates.PointStategetNearestPointState(GameState state, int x, int y)Gets the nearest point for the given screen coordinates.protected static intgetRandomImageIndex(int max)Gets a random image index between 0 and max.intgetXCoordinate(int x)Gets the x center coordinate of the point.intgetYCoordinate(int y)Gets the y center coordinate of the point.static voidloadPointImages()Loads the point images.voidpaint(Graphics g, GameState state)Paints the field on the screen.voidpaintField(Graphics g, GameState state)Paints the field on the given graphics object.protected voidpaintFieldOverlay(Graphics g, GameState state)Paints the field overlay on the given graphics object.voidpaintOccupant(Graphics g, PointState pointState, int xCenter, int yCenter)Paints the occupant of a point.voidpaintPoint(Graphics g, PointState pointState, GameState state, int xCenter, int yCenter)Paints the point.protected voidpaintPointOverlay(Graphics g, PointState p, GameState state, int xCenter, int yCenter)Paints the point overlay (occupant overlay, fog, explosion, target).voidpaintThing(Graphics g, ThingState thingState, GameState state, int xCenter, int yCenter)Paints the thing on the screen.voidpaintThingOverlay(Graphics g, ThingState thingState, GameState state, int xCenter, int yCenter)Paints the thing overlay on the screen.-
Methods inherited from class com.starpoints.painter.PainterBase
draw, drawShaded, drawShaded, getArea, getEditor, getHeight, getIndent, getRepaintFactor, getWidth, getXFactor, getYFactor, isActive, isInputController, onStartGame, setArea, setController, setFontSize, setLevel, setOptions, setState
-
-
-
-
Field Detail
-
TEXT_OFFSET_X
public static final int TEXT_OFFSET_X
x Offset for text painting- See Also:
- Constant Field Values
-
TEXT_OFFSET_Y
public static final int TEXT_OFFSET_Y
y Offset for text painting- See Also:
- Constant Field Values
-
FIELD_MAX_WIDHT
public static final int FIELD_MAX_WIDHT
Maximum supported field width.- See Also:
- Constant Field Values
-
FIELD_MAX_HEIGHT
public static final int FIELD_MAX_HEIGHT
Maximum supported field height.- See Also:
- Constant Field Values
-
OFFSET_LEFT
public static final int OFFSET_LEFT
x Offset for the leftmost point image.- See Also:
- Constant Field Values
-
OFFSET_TOP
public static final int OFFSET_TOP
x Offset for the topmost point image.- See Also:
- Constant Field Values
-
X_FACT
public static final int X_FACT
Width of one point.- See Also:
- Constant Field Values
-
Y_FACT
public static final int Y_FACT
Height of one point.- See Also:
- Constant Field Values
-
HOVER_X_FACT
public static final int HOVER_X_FACT
x factor for hover fx.- See Also:
- Constant Field Values
-
HOVER_Y_FACT
public static final int HOVER_Y_FACT
y factor for hover fx.- See Also:
- Constant Field Values
-
ENERGYFX_X_RADIUS
public static final int ENERGYFX_X_RADIUS
x Radius for regeneration fx.- See Also:
- Constant Field Values
-
ENERGYFX_Y_RADIUS
public static final int ENERGYFX_Y_RADIUS
y Radius for regeneration fx.- See Also:
- Constant Field Values
-
ITEM_ON_FIGURE_X_SIDE
public static final int ITEM_ON_FIGURE_X_SIDE
Factor for calculating rocket fx on figure.- See Also:
- Constant Field Values
-
ITEM_ON_FIGURE_Y_SIDE
public static final int ITEM_ON_FIGURE_Y_SIDE
Factor for calculating rocket fx on figure.- See Also:
- Constant Field Values
-
POINT_RADIUS_X
public static final int POINT_RADIUS_X
Radius for point target fx.- See Also:
- Constant Field Values
-
POINT_RADIUS_Y
public static final int POINT_RADIUS_Y
Radius for point target fx.- See Also:
- Constant Field Values
-
EFFECT_DOTS
public static final int EFFECT_DOTS
Constant for painting dot energy fx.- See Also:
- Constant Field Values
-
EFFECT_BUBBLES
public static final int EFFECT_BUBBLES
Constant for painting bubble energy fx.- See Also:
- Constant Field Values
-
ROCKET_PAINT_WIDTH
public static final int ROCKET_PAINT_WIDTH
Factor for painting rocket fx on figure.- See Also:
- Constant Field Values
-
ROCKET_PAINT_HEIGHT
public static final int ROCKET_PAINT_HEIGHT
Factor for painting rocket fx on figure.- See Also:
- Constant Field Values
-
xp
protected int[] xp
Point x positions.
-
yp
protected int[] yp
Point y positions.
-
blobs
protected java.lang.String[] blobs
-
horizontal
protected java.lang.String horizontal
-
vertical
protected java.lang.String vertical
-
pointImages
protected static java.util.Hashtable<java.lang.Integer,java.lang.String> pointImages
Static hashtable for point image storage.
-
itemImages
protected static transient java.util.Hashtable<java.lang.String,java.lang.String> itemImages
Static hashtable for item image storage.
-
fogImages
protected static transient java.util.Hashtable<java.lang.String,java.lang.String> fogImages
Static hashtable for fog image storage.
-
heatImages
protected static transient java.util.Hashtable<java.lang.String,java.lang.String> heatImages
Static hashtable for heat image storage.
-
painterFactory
protected PainterFactory painterFactory
The PainterFactory.
-
-
Constructor Detail
-
Painter2DArena
public Painter2DArena(PainterFactory painterFactory)
Creates a new painter for a 2D Arena.- Parameters:
painterFactory- The PainterFactory.
-
-
Method Detail
-
getItemImage
public static java.lang.String getItemImage(java.lang.String imageName)
Gets the items image filename for the image with the name specified by getImageName().- Parameters:
imageName- The item imageName.- Returns:
- The imageName + ".png".
-
getFogImage
public static java.lang.String getFogImage(FogState f)
Gets the fogs image to the image with the name specified by getImageName().- Parameters:
f- The fog.- Returns:
- The fogs imageName + ".png".
-
getBaseWidth
public int getBaseWidth()
Gets the base width of this painter.- Specified by:
getBaseWidthin interfacePainter- Overrides:
getBaseWidthin classPainterBase- Returns:
- 1070.
-
getBaseHeight
public int getBaseHeight()
Gets the base height of this painter.- Specified by:
getBaseHeightin interfacePainter- Overrides:
getBaseHeightin classPainterBase- Returns:
- 770.
-
paint
public void paint(Graphics g, GameState state)
Paints the field on the screen.- Specified by:
paintin interfacePainter- Specified by:
paintin classPainterBase- Parameters:
g- The graphics to paint on.state- The game state.
-
paintField
public void paintField(Graphics g, GameState state)
Paints the field on the given graphics object.- Parameters:
g- The graphics object to paint onstate- The gamestate to paint
-
paintFieldOverlay
protected void paintFieldOverlay(Graphics g, GameState state)
Paints the field overlay on the given graphics object.- Parameters:
g- The graphics object to paint onstate- The gamestate
-
paintPoint
public void paintPoint(Graphics g, PointState pointState, GameState state, int xCenter, int yCenter)
Paints the point.- Parameters:
g- The graphics.pointState- The point.state- The GameState.xCenter- The x center coordinate.yCenter- The y center coordinate.
-
paintOccupant
public void paintOccupant(Graphics g, PointState pointState, int xCenter, int yCenter)
Paints the occupant of a point.- Parameters:
g- The graphics.pointState- The point.xCenter- The x center coordinate.yCenter- The y center coordinate.
-
drawPointHeating
protected void drawPointHeating(Graphics g, PointState pointState, GameState state, int xCenter, int yCenter)
Paints a heating effect.- Parameters:
g- The graphics.pointState- The point.state- The GameState.xCenter- The x center coordinate.yCenter- The y center coordinate.
-
getRandomImageIndex
protected static int getRandomImageIndex(int max)
Gets a random image index between 0 and max.- Parameters:
max- The max value.- Returns:
- The random index.
-
paintPointOverlay
protected void paintPointOverlay(Graphics g, PointState p, GameState state, int xCenter, int yCenter)
Paints the point overlay (occupant overlay, fog, explosion, target).- Parameters:
g- The graphics.p- The point.state- The GameState.xCenter- The x center coordinate.yCenter- The y center coordinate.
-
drawPointExplosion
protected static void drawPointExplosion(Graphics g, PointState pointState, int animationIndex, int xCenter, int yCenter)
Performs explosion routine when painting the point.- Parameters:
g- The Graphics to paint on.pointState- The point.animationIndex- The animationIndex.xCenter- x coordinate.yCenter- y coordinate.
-
getNearestPoint
public Point getNearestPoint(int x, int y)
Gets the nearest point for the given screen coordinates.- Parameters:
x- the x coordinate.y- The y coordiante.- Returns:
- The Point nearest to the coordinates.
-
getNearestPointState
public PointState getNearestPointState(GameState state, int x, int y)
Gets the nearest point for the given screen coordinates.- Parameters:
state- The game state.x- the x coordinate.y- The y coordiante.- Returns:
- The Point nearest to the coordinates.
-
getXCoordinate
public int getXCoordinate(int x)
Gets the x center coordinate of the point.- Parameters:
x- The point x coordinate.- Returns:
- The x center.
-
getYCoordinate
public int getYCoordinate(int y)
Gets the y center coordinate of the point.- Parameters:
y- The point y coordinate.- Returns:
- The y center.
-
getField
protected FieldState getField()
Gets the field to display.- Returns:
- The field.
-
applyGraphInfo
public void applyGraphInfo(LevelState levelState)
Calculates new graphic coordinates after resize events.- Parameters:
levelState- The level.
-
getNearestPoint
public Point getNearestPoint(Field f, int x, int y)
Gets the nearest point for the given screen coordinates.- Parameters:
f- The field.x- the x coordinate.y- The y coordiante.- Returns:
- The Point nearest to the coordinates.
-
getNearestPointState
public PointState getNearestPointState(FieldState f, int x, int y)
Gets the nearest PointState for the given screen coordinates.- Parameters:
f- The field.x- the x coordinate.y- The y coordiante.- Returns:
- The Point nearest to the coordinates.
-
getNearestPoint
public Point getNearestPoint(Field f, int x, int y, Rectangle area)
/** Gets the nearest point for the given screen coordinates.- Parameters:
f- The field.x- the x coordinate.y- The y coordiante.area- The painters area.- Returns:
- The Point nearest to the coordinates.
-
paintThing
public void paintThing(Graphics g, ThingState thingState, GameState state, int xCenter, int yCenter)
Paints the thing on the screen.- Parameters:
g- The graphics to paint on.thingState- The thing.state- The GameState.xCenter- The x center coordinate.yCenter- The y center coordinate.
-
paintThingOverlay
public void paintThingOverlay(Graphics g, ThingState thingState, GameState state, int xCenter, int yCenter)
Paints the thing overlay on the screen.- Parameters:
g- The graphics to paint on.thingState- The thing.state- The GameState.xCenter- The x center coordinate.yCenter- The y center coordinate.
-
loadPointImages
public static void loadPointImages()
Loads the point images.
-
-