Super Mario: Bros Java Game 240x320

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

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

private void updateGame() { mario.update(); super mario bros java game 240x320

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

buildLevel(); }

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

// 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); } x += vx; vy += 0

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

Tile(int x, int y, Type t) { this.x = x; this.y = y; this.type = t; } x += vx

@Override public void keyPressed(KeyEvent e) { if (!gameRunning) return; int k = e.getKeyCode(); if (k == KeyEvent.VK_LEFT) mario.left = true; if (k == KeyEvent.VK_RIGHT) mario.right = true; if (k == KeyEvent.VK_SPACE && mario.onGround) { mario.jump(); } }