Super Mario Bros Java - Game 240x320 'link'
// Mario (red shirt, blue overalls, red hat) int marioScreenX = marioX - cameraX; int marioScreenY = marioY; // Overalls g.setColor(0, 0, 200); g.fillRect(marioScreenX, marioScreenY+10, 16, 12); // Skin g.setColor(255, 220, 170); g.fillRect(marioScreenX+2, marioScreenY+2, 12, 10); // Hat g.setColor(200, 0, 0); g.fillRect(marioScreenX, marioScreenY, 16, 6); // Mustache g.setColor(100, 50, 0); g.drawLine(marioScreenX+4, marioScreenY+8, marioScreenX+8, marioScreenY+8); g.drawLine(marioScreenX+8, marioScreenY+8, marioScreenX+12, marioScreenY+8);
| Class | Responsibility | |-------|----------------| | MarioCanvas | Extends javax.microedition.lcdui.GameCanvas ; handles rendering, input, game loop | | MarioMIDlet | Manages application lifecycle ( startApp , pauseApp , destroyApp ) | | Player | Position, velocity (fixed-point), animation states, collision AABB | | TileMap | 240×320 world divided into 16×16 tiles; scrolling viewport | | Enemy | Goomba/Koopa behavior, AI, collision response | | GameCamera | Scroll offset (max world width: 3200 pixels) | | CollisionManager | Tile-based collision + entity collision |
Note that some older devices require both JAR and JAD files, though most modern feature phones can install from a JAR alone.
public void start() gameThread = new Thread(this); gameThread.start();
The game relied on Java 2 Micro Edition (J2ME). This technology allowed developers to compress entire gaming worlds into tiny JAR files. These files were often smaller than 500 Kilobytes. super mario bros java game 240x320
private void update() // Handle jumping and collision detection // ...
// Mario physics private int marioX = 50, marioY = 200; private int marioVelX = 0, marioVelY = 0; private boolean onGround = false; private static final int GRAVITY = 1; private static final int JUMP_POWER = -12;
: Unlike the original NES version, many Java ports allowed players to save progress at the start of each level, catering to short mobile gaming sessions. Popular Java Variations Key Characteristic Super Mario Bros 3-in-1 Includes adapted versions of the first three NES titles. Super Mario Forever
Used Graphics from getGraphics() with manual flush to avoid flicker: // Mario (red shirt, blue overalls, red hat)
if (marioY + 20 > pY && marioY < pY + pH && marioX + 15 > pX && marioX < pX + pW) // Top collision if (marioVelY > 0 && marioY + 20 - marioVelY <= pY) marioY = pY - 20; marioVelY = 0; onGround = true;
In the mid-2000s, the 240x320 screen was the "Goldilocks" zone for mobile displays—just enough detail to render Mario’s sprites without lagging the limited hardware.
Desktop users can run Java games directly without an emulator, provided the game is packaged as a standard JAR file. , for instance, runs on any system with Java Runtime Environment (JRE) 1.4 or later. Simply double-click the Mario.jar file to launch the game.
: Optimized for numerical keypads where 2 is jump, 4/6 are directional movements, and 5 is typically for firing projectiles. These files were often smaller than 500 Kilobytes
The version is a classic mobile adaptation of the legendary NES title, designed specifically for feature phones with portrait-oriented screens. It prioritizes smooth performance and faithful level recreation despite the hardware limitations of the Java platform. Core Gameplay Features
While these games are no longer commercially sold, enthusiasts can still experience them:
: The original NES ran at 256x240 pixels. Java developers rotated and scaled sprites to fit the vertical 240x320 mobile screens.