Super Mario | Bros Java Game 240x320

// --- Flag --- class Flag { int x, y; Flag(int x, int y) { this.x = x; this.y = y; } Rectangle getBounds() { return new Rectangle(x, y, 8, 16); } void draw(Graphics2D g, int screenX, int screenY) { g.setColor(Color.RED); g.fillRect(screenX, screenY, 4, 20); g.fillPolygon(new int[]{screenX + 4, screenX + 16, screenX + 4}, new int[]{screenY, screenY + 8, screenY + 16}, 3); } }

// ground and platforms for (int x = 0; x < levelWidth; x++) { // ground at y = 18 tiles (288px) tiles[x][18] = new Tile(x * TILE_SIZE, 18 * TILE_SIZE, Tile.Type.GROUND); } super mario bros java game 240x320

// coins coins.add(new Coin(15 * TILE_SIZE, 14 * TILE_SIZE)); coins.add(new Coin(42 * TILE_SIZE, 12 * TILE_SIZE)); coins.add(new Coin(43 * TILE_SIZE, 12 * TILE_SIZE)); coins.add(new Coin(60 * TILE_SIZE, 17 * TILE_SIZE)); // --- Flag --- class Flag { int

// flag collision if (mario.getBounds().intersects(flag.getBounds())) { gameWin = true; gameRunning = false; } int y) { this.x = x

// goombas goombas.add(new Goomba(20 * TILE_SIZE, 18 * TILE_SIZE - 16)); goombas.add(new Goomba(44 * TILE_SIZE, 13 * TILE_SIZE - 16)); goombas.add(new Goomba(65 * TILE_SIZE, 18 * TILE_SIZE - 16));