Super Mario Bros Java Game 240x320 Updated -
You can copy this code into a single .java file and run it as a Java Swing application.
@Override public void keyTyped(KeyEvent e) {}
// goombas Iterator<Goomba> goombaIt = goombas.iterator(); while (goombaIt.hasNext()) Goomba g = goombaIt.next(); g.update(); if (mario.getBounds().intersects(g.getBounds())) if (mario.vy > 0 && mario.y + mario.height - g.y < 16) // stomp goombaIt.remove(); score += 20; mario.vy = -8; // small bounce else gameRunning = false; // game over super mario bros java game 240x320
Mario(int startX, int groundY) x = startX; y = groundY - height;
onGround = false; if (y + height > SCREEN_HEIGHT) y = SCREEN_HEIGHT - height; vy = 0; onGround = true; You can copy this code into a single
In the mid-2000s, before the iPhone revolutionized touchscreen gaming, a different kind of hero dominated the mobile landscape: games. Among the most coveted titles for any feature phone was the port of Nintendo’s mascot. If you owned a Sony Ericsson, Nokia, or Samsung phone with a 240x320 pixel resolution (often referred to as QVGA), you were in for a treat.
// mario mario.draw(g2, mario.x - cameraX, mario.y); If you owned a Sony Ericsson, Nokia, or
: Sprites were often ripped from Super Mario Advance or Super Mario All-Stars and downsampled to fit the 16-bit or 8-bit color depth typical of mobile screens.
// coins Iterator<Coin> coinIt = coins.iterator(); while (coinIt.hasNext()) Coin c = coinIt.next(); if (mario.getBounds().intersects(c.getBounds())) coinIt.remove(); score += 10;
Rectangle getBounds() return new Rectangle(x, y, TILE_SIZE, TILE_SIZE);