Esempio n. 1
0
  // Draws the minimap
  public void draw() {

    // A new image is created for the minimap, drawn onto, and the applied as the Actor's image
    // Drawing of the minimap is done this way so that there won't be any artifacting when draw() is
    // called by a thread other than the main thread
    GreenfootImage image = new GreenfootImage(FRAME.width, FRAME.height);
    image.setTransparency(150);

    // Get map
    ArrayList<ArrayList<Tile>> map = Data.tiles();

    // Position of the minimap tile being drawn
    int x = 0;
    int y = 0;

    // Iterate through every map tile and draw it onto minimap, adjusting the position for the next
    // tile with each iteration
    // Minimap is drawn column by column
    for (int i = 0; i < Map.getInstance().SIZE_COLUMNS; i++) {
      for (int j = 0; j < Map.getInstance().SIZE_ROWS; j++) {

        Tile tile = (Tile) map.get(i).get(j);
        // Get the color to draw based on either the tile's type or zone (if zoned)
        if (tile.zone() > 0) {
          image.setColor(colorForTileOfZone(tile.zone()));
        } else {
          image.setColor(colorForTileOfType(tile.type()));
        }

        image.fillRect(x, y, tileSize, tileSize); // Minimap tiles are 2px * 2px
        y += tileSize;
      }

      // Reset Y to top of the column
      y = 0;

      x += tileSize;
    }

    setImage(image);
  }
Esempio n. 2
0
 /**
  * Act - do whatever the Help wants to do. This method is called whenever the 'Act' or 'Run'
  * button gets pressed in the environment.
  */
 public void act() {
   super.act();
   imgHelp.setTransparency(255);
   click();
 }
Esempio n. 3
0
 /** Construtor, desenha uma caixa, faz print do texto e inicializa o objeto help */
 public Helpbt() {
   drawBox();
   printText();
   help = new Help();
   imgHelp.setTransparency(0);
 }