Super Mario Bros Java Game 240x320 «2025-2027»
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.Iterator;public class MarioGame extends JPanel implements ActionListener, KeyListener { private static final int WIDTH = 240; private static final int HEIGHT = 320; private static final int GROUND_Y = 280;
// Mario private int marioX = 50, marioY = GROUND_Y - 20; private int marioVelX = 0, marioVelY = 0; private boolean onGround = true; private final int MARIO_WIDTH = 16, MARIO_HEIGHT = 20; // World private ArrayList<Platform> platforms; private ArrayList<Goomba> goombas; private ArrayList<Coin> coins; private int score = 0; private boolean gameOver = false; private Timer timer; public MarioGame() setPreferredSize(new Dimension(WIDTH, HEIGHT)); setBackground(Color.CYAN); setFocusable(true); addKeyListener(this); initLevel(); timer = new Timer(16, this); // ~60 FPS timer.start(); private void initLevel() platforms = new ArrayList<>(); // Ground platforms.add(new Platform(0, GROUND_Y, WIDTH, 10)); // Left platform platforms.add(new Platform(40, 250, 60, 10)); // Middle platform platforms.add(new Platform(120, 220, 60, 10)); // Right high platform platforms.add(new Platform(190, 180, 50, 10)); goombas = new ArrayList<>(); goombas.add(new Goomba(100, GROUND_Y - 15, 15, 15)); goombas.add(new Goomba(180, 250 - 15, 15, 15)); coins = new ArrayList<>(); coins.add(new Coin(60, 230, 8, 8)); coins.add(new Coin(140, 195, 8, 8)); coins.add(new Coin(200, 155, 8, 8)); marioX = 50; marioY = GROUND_Y - MARIO_HEIGHT; marioVelX = 0; marioVelY = 0; score = 0; gameOver = false; @Override public void actionPerformed(ActionEvent e) if (!gameOver) updateGame(); repaint(); private void updateGame() // Apply gravity marioVelY += 1; marioY += marioVelY; // Horizontal movement marioX += marioVelX; // Collision with platforms onGround = false; for (Platform p : platforms) if (marioY + MARIO_HEIGHT > p.y && marioY + MARIO_HEIGHT <= p.y + p.height + marioVelY && marioX + MARIO_WIDTH > p.x && marioX < p.x + p.width) marioY = p.y - MARIO_HEIGHT; marioVelY = 0; onGround = true; // Head bump (optional) if (marioY < p.y + p.height && marioY + MARIO_HEIGHT > p.y + p.height && marioX + MARIO_WIDTH > p.x && marioX < p.x + p.width && marioVelY < 0) marioY = p.y + p.height; marioVelY = 0; // World boundaries if (marioX < 0) marioX = 0; if (marioX + MARIO_WIDTH > WIDTH) marioX = WIDTH - MARIO_WIDTH; if (marioY + MARIO_HEIGHT > GROUND_Y + 10) gameOver = true; // Update enemies for (Goomba g : goombas) g.update(); // Enemy collision (game over) if (marioX < g.x + g.w && marioX + MARIO_WIDTH > g.x && marioY < g.y + g.h && marioY + MARIO_HEIGHT > g.y) gameOver = true; // Collect coins Iterator<Coin> it = coins.iterator(); while (it.hasNext()) Coin c = it.next(); if (marioX < c.x + c.size && marioX + MARIO_WIDTH > c.x && marioY < c.y + c.size && marioY + MARIO_HEIGHT > c.y) it.remove(); score += 10; // Jumping logic if (onGround && marioVelY == 0) // can jump in keyPressed @Override public void paintComponent(Graphics g) super.paintComponent(g); // Draw sky g.setColor(Color.CYAN); g.fillRect(0, 0, WIDTH, HEIGHT); // Draw platforms (brown) g.setColor(new Color(139, 69, 19)); for (Platform p : platforms) g.fillRect(p.x, p.y, p.width, p.height); // Draw coins (yellow) g.setColor(Color.YELLOW); for (Coin c : coins) g.fillOval(c.x, c.y, c.size, c.size); // Draw Goombas (dark brown) g.setColor(new Color(80, 50, 30)); for (Goomba gb : goombas) g.fillRect(gb.x, gb.y, gb.w, gb.h); g.setColor(Color.BLACK); g.fillRect(gb.x + 3, gb.y + 3, 3, 3); g.fillRect(gb.x + 9, gb.y + 3, 3, 3); g.setColor(new Color(80, 50, 30)); // Draw Mario (red with hat) g.setColor(Color.RED); g.fillRect(marioX, marioY, MARIO_WIDTH, MARIO_HEIGHT); g.setColor(Color.BLUE); g.fillRect(marioX + 2, marioY - 4, 12, 4); // hat g.setColor(Color.WHITE); g.fillRect(marioX + 4, marioY + 4, 3, 3); // eye // Score g.setColor(Color.BLACK); g.setFont(new Font("Arial", Font.BOLD, 12)); g.drawString("Score: " + score, 10, 20); if (gameOver) g.setColor(Color.RED); g.setFont(new Font("Arial", Font.BOLD, 20)); g.drawString("GAME OVER", WIDTH/2 - 60, HEIGHT/2); g.setFont(new Font("Arial", Font.PLAIN, 12)); g.drawString("Press R to restart", WIDTH/2 - 50, HEIGHT/2 + 30); @Override public void keyPressed(KeyEvent e) if (gameOver && e.getKeyCode() == KeyEvent.VK_R) initLevel(); return; if (gameOver) return; int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) marioVelX = -3; else if (key == KeyEvent.VK_RIGHT) marioVelX = 3; else if (key == KeyEvent.VK_SPACE @Override public void keyReleased(KeyEvent e) @Override public void keyTyped(KeyEvent e) {} // Helper classes class Platform int x, y, width, height; Platform(int x, int y, int w, int h) this.x = x; this.y = y; width = w; height = h; class Goomba int x, y, w, h; int dir = 1; Goomba(int x, int y, int w, int h) this.x = x; this.y = y; this.w = w; this.h = h; void update() x > WIDTH - 50 - w) dir *= -1; class Coin int x, y, size; Coin(int x, int y, int s) this.x = x; this.y = y; size = s; public static void main(String[] args) JFrame frame = new JFrame("Super Mario Bros - 240x320"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.add(new MarioGame()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
}
The million-dollar question for any retro fan is: Does it feel like the real Super Mario Bros?
The Java version, specifically the one produced by various mobile studios (often unlicensed or commissioned by Nintendo for specific Asian/European markets), was surprisingly faithful. Here’s what you could expect:
Nintendo was cautious with mobile licensing, but they released official versions through i-mode and specific carriers in Japan and Europe. These are the gold standard. They have "Nintendo" on the loading screen and perfect physics.
Gameloft made "Prince of Persia" and "Asphalt," but they never made Mario. However, Mario-style platformers like "Midnight Bowling" (joking) – actually, look for "Super Mario" by Oxygen Games or "Mario Bros (Mobile)" by In-Fusio.
Contrary to popular belief, Nintendo did release official Java-based Mario games, but not under the simple "Super Mario Bros" name. In 2004-2007, Nintendo collaborated with mobile developers like i-mode and Gameloft (under license) to produce titles such as:
These official versions ran beautifully at 240x320. They featured Nintendo’s exact sprite work, original sound effects (beep-based), and tight controls. However, they were region-locked and required carrier-specific downloads (e.g., Vodafone live!). Thus, they are incredibly rare today.
To understand the significance of this specific resolution, we have to go back to the hardware limitations of 2005–2010. Mobile screens were divided into three tiers: super mario bros java game 240x320
The 240x320 resolution was a breakthrough because it provided an aspect ratio close to 3:4, which, when playing a landscape game (by tilting the phone sideways or using a virtual horizontal view), allowed developers to render Mario at a scale where you could actually see his hat, eyes, and mustache. More importantly, it gave enough horizontal buffer to see incoming Goombas before they hit you—a luxury smaller resolutions couldn't afford.
In the golden era of mobile gaming (around 2005-2010), a Java-based Super Mario Bros.
resolution typically followed a simplified version of the classic Nintendo narrative, tailored for the limited memory of early mobile devices. The Core Story: "The Mushroom Crystal Heist"
In this mobile-specific retelling, the story shifts from a simple rescue to a quest involving a magical artifact that powers the kingdom. The Incident
: Bowser has not only kidnapped Princess Toadstool but has also stolen the Grand Mushroom Crystal
. Without it, the Mushroom Kingdom is slowly losing its color and turning into a pixelated wasteland. The Mission
: Mario and Luigi must travel across four distinct "Zonal Chapters" to recover crystal shards before reaching Bowser’s sky-high fortress. Chapter Breakdown
Because Java mobile games often used small "jar" file sizes (often under 1MB), the story is told through brief text boxes between worlds. History of Java Games - Smart Zeros (Ukrainian Project)
The Super Mario Bros. Java version for the 240x320 resolution is a classic example of "demaking" console games for early 2000s mobile phones. These games were built using J2ME (Java 2 Platform, Micro Edition) to run on devices like Nokia, Sony Ericsson, and Motorola. Retro Gaming on Mobile import javax
Resolution: 240x320 was the "standard" portrait size for mid-to-high-end feature phones. Platform: J2ME (.jar and .jad files).
Controls: Optimized for numeric keypads (usually 2, 4, 6, 8 for movement and 5 for action). Common Versions
Most "Super Mario Bros" games found on Java forums back in the day were not official Nintendo products. Instead, they were:
Unofficial Clones: Developers like "Digital Chocolate" or "Gameloft" often made Mario-style platformers, but fans would reskin them with Mario sprites.
Emulators: Some users used specialized Java-based NES emulators to play the original ROM on their phones.
Fan Projects: Homebrew versions that recreated the first few levels of the NES original with varying levels of physics accuracy.
💡 Fun Fact: The original NES Super Mario Bros. was only 32 KB in size. Java mobile versions were often larger because they had to bundle the J2ME engine and sound files specifically for mobile hardware.
The Pixelated Legend: Revisiting Super Mario Bros on Java (240x320)
Before the era of sleek smartphones and high-definition mobile gaming, there was the Java (J2ME) age—a time when getting a console-quality experience on your phone felt like magic. Among the most sought-after titles for Nokia, Sony Ericsson, and Motorola handsets was the legendary Super Mario Bros. Java game , specifically optimized for the 240x320 screen resolution. The million-dollar question for any retro fan is:
While Nintendo never officially released a classic Mario port for J2ME, the community stepped in with impressive recreations that became staples of the mobile gaming underground. The Charm of the 240x320 Port
The 240x320 resolution was the "Goldilocks zone" for classic mobile phones. It offered enough vertical and horizontal space to maintain the original NES aspect ratio without too much distortion. Key features of these Java versions included:
Adapted Graphics: Sprites and tiles were often slightly downscaled or hand-drawn to fit the limited color palettes and memory of Java-enabled phones.
Physics Accuracy: Some of the most popular builds, such as the "Super Mario Bros 3-in-1" collections, managed to replicate Mario’s iconic momentum and jump physics with surprising precision.
Sound Emulation: While many J2ME games used simple MIDI files, high-quality Mario ports often included the original Koji Kondo soundtrack, compressed into tiny file sizes. Gameplay & Mechanics
Despite the hardware limitations, these Java versions aimed to deliver a full-fat Mario experience:
Classic Level Design: Recreations often featured the full 8-world structure of the 1985 original, including secret warp pipes and bonus coin rooms.
Controls: Most games mapped movement to the directional pad or the '2', '4', '6', and '8' keys, with '5' or '0' typically serving as the jump button. Later PC-based Java implementations even added gamepad support.
Portability: At just a few hundred kilobytes, you could carry the entire Mushroom Kingdom in your pocket, a feat that felt revolutionary in the mid-2000s. Why it Matters Today
For many, these .jar files were their first introduction to Nintendo’s mascot. In a world before the official Super Mario Run launched in 2016, these community-driven projects were the only way to play Mario on the go.
Modern developers still use Mario as a "hello world" for learning Java game development. You can find numerous projects on SourceForge and GitHub that continue to refine the code for modern systems, proving that the foundation laid by these 240x320 mobile versions is still relevant. jar files on modern Android or PC devices? 1 3 Mario Games for Java Review