Super Mario Bros Java — Game 240x320

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

// coins for (Coin c : coins) { c.draw(g2, c.x - cameraX, c.y); }

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); } } super mario bros java game 240x320

// Game state private boolean gameRunning = true; private boolean gameWin = false; private int score = 0;

@Override public void actionPerformed(ActionEvent e) { if (gameRunning && !gameWin) { updateGame(); } repaint(); } private void initGame() { mario = new Mario(32,

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

initGame(); timer = new Timer(16, this); // ~60 FPS timer.start(); } // start x

x += vx; vy += 0.5; y += vy;