public void paintWorld(final Graphics g) { // per il debugging // //////*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ int width = World.X_MATRIX_STRING * AbstractBlockRoadObject.getSize(); int height = World.Y_MATRIX_STRING * AbstractBlockRoadObject.getSize(); double dimention = 1.0; for (double i = 0; i < width; i++) { for (double j = 0; j < height; j++) { if (game.getWorld() .getMatrixWorld() .getValuePosition((int) (i / dimention), (int) (j / dimention)) == 1) { g.setColor(Color.GREEN); g.fillRect((int) j + I, (int) i + J, 1, 1); } if (game.getWorld() .getMatrixWorld() .getValuePosition((int) (i / dimention), (int) (j / dimention)) == 2) { g.setColor(Color.RED); g.fillRect((int) j + I, (int) i + J, 1, 1); } } } }
public void paintStart(Graphics2D g) { /* FOR DEBUG */ int width = World.X_MATRIX_STRING * AbstractBlockRoadObject.getSize(); int height = World.Y_MATRIX_STRING * AbstractBlockRoadObject.getSize(); double dimention = 1.0; for (double i = 0; i < width; i++) { for (double j = 0; j < height; j++) { if (game.getWorld() .getMatrixWorld() .getValuePosition((int) (i / dimention), (int) (j / dimention)) == BlockRoadObject.START) { g.setColor(Color.WHITE); g.fillRect((int) j + I, (int) i + J, 1, 1); } } } }
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); }
private void paintCornice(final Graphics g) { int x = I - AbstractBlockRoadObject.getSize(); int y = J - AbstractBlockRoadObject.getSize(); g.drawImage(ImageProvider.getBoardEdgeUpLeft(), x, y, null); g.drawImage( ImageProvider.getBoardEdgeDownRight(), World.Y_MATRIX_STRING * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), World.X_MATRIX_STRING * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); g.drawImage( ImageProvider.getBoardEdgeUpRight(), World.Y_MATRIX_STRING * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), y, null); g.drawImage( ImageProvider.getBoardEdgeDownLeft(), x, World.X_MATRIX_STRING * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); for (int i = 0; i < World.Y_MATRIX_STRING; i++) { g.drawImage( ImageProvider.getBoardHigh(), i * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), 0 + y, null); g.drawImage( ImageProvider.getBoardDown(), i * AbstractBlockRoadObject.getSize() + x + AbstractBlockRoadObject.getSize(), (World.X_MATRIX_STRING + 1) * AbstractBlockRoadObject.getSize() + y, null); } for (int i = 0; i < World.X_MATRIX_STRING; i++) { g.drawImage( ImageProvider.getBoardLeft(), 0 + x, i * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); g.drawImage( ImageProvider.getBoardRight(), (World.Y_MATRIX_STRING + 1) * AbstractBlockRoadObject.getSize() + x, i * AbstractBlockRoadObject.getSize() + y + AbstractBlockRoadObject.getSize(), null); } }
private void paintWorldImage(final Graphics g) { // moveCamera(); 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.getHorizontal(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("vertical".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getVertical(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curveleftup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getUpLeft(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curveleftdown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getDownLeft(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curverightup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getUpRigth(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("curverightdown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getDownRight(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("grass".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getGrass(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("starthorizontalright".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStart(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("starthorizontalleft".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStart(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("startverticalup".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStartVertical(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } if ("startverticaldown".equals(game.getWorld().getMatrixString()[i][j])) { g.drawImage( ImageProvider.getStartVertical(), j * AbstractBlockRoadObject.getSize() + I, i * AbstractBlockRoadObject.getSize() + J, null); } } } }