/** Make the score board image. */ private void makeImage(String title, String text, String prefix, int score) { GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT); image.setColor(new Color(0, 0, 0, 128)); image.fillRect(0, 0, WIDTH, HEIGHT); image.setColor(new Color(0, 0, 0, 128)); image.fillRect(5, 5, WIDTH - 10, HEIGHT - 10); Font font = image.getFont(); font = font.deriveFont(FONT_SIZE); image.setFont(font); image.setColor(Color.WHITE); image.drawString(title, 60, 100); image.drawString(text, 60, 220); image.drawString(prefix + score, 60, 320); setImage(image); }
public void fade(int f) { if (f > 255) { f = 255; } else if (f < 0) { f = 0; } fadeColor = new Color(0, 0, 0, f); fade.clear(); fade.setColor(fadeColor); fade.fillRect(0, 0, 1280, 720); setImage(fade); }
private void drawBox() { amarelo = new Color(255, 188, 0); laranja = new Color(255, 133, 0); imgHelp = getImage(); imgHelp.setColor(laranja); imgHelp.fill(); imgHelp.scale(200, 50); imgHelp.setColor(amarelo); int margem = 5; int largura = imgHelp.getWidth() - 2 * margem; int altura = imgHelp.getHeight() - 2 * margem; imgHelp.fillRect(margem, margem, largura, altura); }
// 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); }