Super — Mario Bros Java Game 240x320

@Override public void actionPerformed(ActionEvent e) { if (gameRunning && !gameWin) { updateGame(); } repaint(); }

Rectangle getBounds() { return new Rectangle(x, y, TILE_SIZE, TILE_SIZE); }

void jump() { vy = -9; onGround = false; }

Rectangle getBounds() { return new Rectangle(x, y, width, height); } super mario bros java game 240x320

void draw(Graphics2D g, int screenX, int screenY) { g.setColor(Color.RED); g.fillRect(screenX, screenY, width, height); g.setColor(Color.BLACK); g.fillRect(screenX + 4, screenY + 4, 2, 2); g.fillRect(screenX + 10, screenY + 4, 2, 2); } }

// Game objects private ArrayList<Coin> coins; private ArrayList<Goomba> goombas; private Flag flag;

// goombas for (Goomba g : goombas) { g.draw(g2, g.x - cameraX, g.y); } onGround = false

// collision with tiles handleTileCollisions();

private void initGame() { mario = new Mario(32, 240); // start x, ground y coins = new ArrayList<>(); goombas = new ArrayList<>();

public MarioGame240x320() { setPreferredSize(new Dimension(SCREEN_WIDTH, SCREEN_HEIGHT)); setBackground(Color.CYAN); setFocusable(true); addKeyListener(this); } void draw(Graphics2D g

// 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));

// platform at x 40-45, y=13 for (int x = 40; x <= 45; x++) { tiles[x][13] = new Tile(x * TILE_SIZE, 13 * TILE_SIZE, Tile.Type.GROUND); }