Esempio n. 1
0
  private void renderGUIControls(Graphics g) {

    Collection<Sprite> decorSprites = game.getGUIDecor().values();
    for (Sprite s : decorSprites) {
      if (!s.getSpriteType().getSpriteTypeID().equals(BACKGROUND_TYPE)) renderSprite(g, s);
    }

    Collection<Sprite> buttonSprites = game.getGUIButtons().values();
    for (Sprite s : buttonSprites) renderSprite(g, s);
  }
Esempio n. 2
0
  /**
   * This is where rendering starts. This method is called each frame, and the entire game
   * application is rendered here with the help of a number of helper methods.
   *
   * @param g The Graphics context for this panel.
   */
  @Override
  public void paintComponent(Graphics g) {

    try {
      // MAKE SURE WE HAVE EXCLUSIVE ACCESS TO THE GAME DATA
      game.beginUsingData();

      // CLEAR THE PANEL
      super.paintComponent(g);

      // RENDER THE BACKGROUND, WHICHEVER SCREEN WE'RE ON
      renderBackground(g);

      // Render these things if the game as has started.
      if (!dataModel.notStarted()) {

        //                RENDER THE CARS IF THE LEVEL HASN'T BEEN WON YET
        //               if (!dataModel.won())
        //                    renderCars(g);
        //
        //                RENDER THE GRAPH, INCLUDING THE ROADS AND NODES.
        //                renderGraph();
        //
        //                RENDER DIALOGS IF THERE ARE ANY.
        //                renderDialogs(g);
        //                //
        //                renderLevelName(g);

      }
      if (((PathXMiniGame) game).isCurrentScreenState(LEVEL_SELECT_SCREEN_STATE)) {
        renderMap(g);
        renderLevelSelectStats(g);
        updateLevelSprites();
      }

      // RENDER BUTTONS AND DECOR
      renderGUIControls(g);

      // renderStats(g);

    } finally {
      game.endUsingData();
    }
  }
Esempio n. 3
0
  /**
   * This constructor stores the game and data references, which we'll need for rendering.
   *
   * @param initGame The pathX game that is using this panel for rendering.
   * @param initData The pathX game data.
   */
  public PathXPanel(MiniGame initGame, PathXDataModel initData) {

    game = initGame;
    dataModel = initData;
    numberFormatter = NumberFormat.getNumberInstance();
    numberFormatter.setMinimumFractionDigits(3);
    numberFormatter.setMaximumFractionDigits(3);
    map =
        game.loadImage(
            props.getProperty(PathXPropertyType.PATH_IMG)
                + props.getProperty(PathXPropertyType.IMAGE_MAP));
    eventHandler = ((PathXMiniGame) game).getEventHandler();
  }
Esempio n. 4
0
  public void renderBackground(Graphics g) {

    Sprite bg = game.getGUIDecor().get(BACKGROUND_TYPE);
    renderSprite(g, bg);
  }