Beispiel #1
0
 private void paintAlphabet(IAlphabet iAlphabet) {
   Text text = new Text(iAlphabet.getAlphabet());
   actors.put(iAlphabet.getAlphabet(), text);
   Board board = (Board) getWorld();
   if (board == null) {
     System.out.println("NULL");
   }
   board.addObject(text, iAlphabet.getX(), iAlphabet.getY());
 }
Beispiel #2
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);
  }
Beispiel #3
0
 public void repaint() {
   // Iterator itr = alphabets.entrySet().iterator();
   Board board = (Board) getWorld();
   List<Text> remainingActors = board.getObjects(Text.class);
   board.removeObjects(remainingActors);
   // itr = null;
   // itr = alphabets.entrySet().iterator();
   actors.clear();
   for (IAlphabet iAlphabet : alphabets) {
     paintAlphabet(iAlphabet);
   }
 }
Beispiel #4
0
 public void removeAlphabet(String alphabet) {
   Text text = actors.get(alphabet);
   Board board = (Board) getWorld();
   board.removeObject(text);
 }