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

    int size = 40;
    int I = dim.width - size * World.Y_MATRIX_STRING;
    int J = 0;

    for (int i = 0; i < World.X_MATRIX_STRING; i++) {
      for (int j = 0; j < World.Y_MATRIX_STRING; j++) {

        if ("horizontal".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMinihorizontal(), j * size + I, i * size + J, null);
        }
        if ("vertical".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMinivertical(), j * size + I, i * size + J, null);
        }
        if ("curveleftup".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMiniLeftup(), j * size + I, i * size + J, null);
        }
        if ("curveleftdown".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMiniLeftdown(), j * size + I, i * size + J, null);
        }
        if ("curverightup".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMiniRigthup(), j * size + I, i * size + J, null);
        }
        if ("curverightdown".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMiniRightdown(), j * size + I, i * size + J, null);
        }
        if ("grass".equals(game.getWorld().getMatrixString()[i][j])) {
          // g.drawImage(ImageProvider.getMinigrass(),
          // j*size+I,i*size+J, null);
        }
        if ("starthorizontalright".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMinistarthorizontal(), j * size + I, i * size + J, null);
        }
        if ("starthorizontalleft".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMinistarthorizontal(), j * size + I, i * size + J, null);
        }
        if ("startverticalup".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMinistartvertical(), j * size + I, i * size + J, null);
        }
        if ("startverticaldown".equals(game.getWorld().getMatrixString()[i][j])) {
          g.drawImage(ImageProvider.getMinistartvertical(), j * size + I, i * size + J, null);
        }
      }
    }

    g.setColor(Color.RED);

    g.fillRect(
        (int)
            (game.getWorld().getCar2().getX1()
                    / ((double) AbstractBlockRoadObject.getSize() / (double) size)
                + I),
        (int)
            (game.getWorld().getCar2().getY1()
                    / ((double) AbstractBlockRoadObject.getSize() / (double) size)
                + J),
        6,
        6);

    g.setColor(Color.YELLOW);

    g.fillRect(
        (int)
            (game.getWorld().getCar().getX1()
                    / ((double) AbstractBlockRoadObject.getSize() / (double) size)
                + I),
        (int)
            (game.getWorld().getCar().getY1()
                    / ((double) AbstractBlockRoadObject.getSize() / (double) size)
                + J),
        6,
        6);
  }