Package view

Class GameFieldRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
GameField

public class GameFieldRenderer extends JPanel
Implements the game's rendering engine.
See Also:
  • Field Details

    • scale

      protected static int scale
      The scaling of the game.
    • xLength

      protected final int xLength
      The height of the panel.
    • yLength

      protected final int yLength
      The width of the panel.
    • controlPanel

      protected final ControlPanel controlPanel
      ControlPanel component.
    • hamburgerMenu

      protected final HamburgerMenu hamburgerMenu
      HamburgerMenu component.
    • mapRef

      protected Map mapRef
      Reference to a Map instance.
    • selection

      protected Entity selection
      The selected Entity.
    • frame

      protected static JFrame frame
      The parent frame.
    • game

      protected Game game
      The Game dependency.
    • middleText

      protected String middleText
      Text field 1 on the HUD.
    • sideText

      protected String sideText
      Text field 2 on the HUD.
  • Constructor Details

    • GameFieldRenderer

      public GameFieldRenderer(Game game, JFrame frame)
      Constructs a GameFieldRenderer instance.
      Parameters:
      game - Game dependency injection
      frame - the parent frame
  • Method Details

    • getScale

      public static int getScale()
      Returns the current scale.
      Returns:
      the current scale
    • dockScale

      public static int dockScale()
      Returns the dock's scale.
      Returns:
      the dock's scale
    • toggleScale

      public void toggleScale()
      Toggles the scale.
    • toggleTextures

      public void toggleTextures()
      Toggles the textures.
    • renderField

      protected void renderField(Graphics2D g2d)
      Renders the canvas
      Parameters:
      g2d - the graphics we use
    • drawTile

      protected void drawTile(Graphics2D g2d, int x, int y)
      Draws the selected tile.
      Parameters:
      g2d - the graphics we use
      x - the horizontal coordinate
      y - the vertical coordinate
    • drawWayPoints

      protected void drawWayPoints(Graphics2D g2d)
      Draws the waypoints
      Parameters:
      g2d - the graphics we use
    • drawEnt

      protected void drawEnt(Graphics2D g2d, int x, int y)
      Draws the selected Entity.
      Parameters:
      g2d - the graphics we use
      x - the horizontal coordinate
      y - the vertical coordinate
    • paintComponent

      protected void paintComponent(Graphics g)
      The paintComponent method of the class.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - graphics we use
    • drawHealthBar

      protected void drawHealthBar(Graphics2D g2d, Entity entity)
      Draws the health bar of the unit
      Parameters:
      g2d - the graphics we use
      entity - the unit we want to draw the health bar of
    • drawAvgHealthBar

      protected void drawAvgHealthBar(Graphics2D g2d, ArrayList<Entity> entities)
      Draws the avg health bar of the units
      Parameters:
      g2d - the graphics we use
      entities - the units we want to draw the avg health bar of
    • drawPath

      protected void drawPath(Graphics2D g2d, Soldier soldier)
      Draws the paths
      Parameters:
      g2d - the graphics we use
      soldier - the path we want to draw
    • drawAnimated

      protected void drawAnimated(Graphics2D g2d)
      Draws the animated units
      Parameters:
      g2d - the graphics we use
    • drawBuildingState

      protected void drawBuildingState(Graphics2D g2d, Entity entity)
      Draws a building's visible attributes
      Parameters:
      g2d - the graphics we use
      entity - the building to draw to
    • drawCurrentSelection

      protected void drawCurrentSelection(Graphics2D g2d)
      Draws the current selection
      Parameters:
      g2d - the graphics we use
    • drawLabels

      public void drawLabels(Graphics2D g2d)
      Draws the HUD's labels.
      Parameters:
      g2d - the graphics we use
    • setSelection

      protected void setSelection(Entity entity)
      Sets the selection to a new Entity.
      Parameters:
      entity - the entity to set to
    • handleType

      protected void handleType(Graphics2D g2d, Types type)
      Defines which color to use when drawing an Entity.
      Parameters:
      g2d - the graphics we use
      type - the type to handle
    • setTextures

      public void setTextures()
      Sets textures
    • drawImage

      public void drawImage(Graphics2D g2d, Terrain ter, int x, int y)
      Draws the textures.
      Parameters:
      g2d - the graphics we use
      ter - the terrain to draw
      x - the x coordinate
      y - the y coordinate