Class Painter2DArena

    • 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
      • 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".
      • paint

        public void paint​(Graphics g,
                          GameState state)
        Paints the field on the screen.
        Specified by:
        paint in interface Painter
        Specified by:
        paint in class PainterBase
        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 on
        state - 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 on
        state - 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.