Skip to content

Instantly share code, notes, and snippets.

@shricodev
Created May 25, 2025 14:27
Show Gist options
  • Save shricodev/1b2a080260d408e9964905631b621f38 to your computer and use it in GitHub Desktop.
Save shricodev/1b2a080260d408e9964905631b621f38 to your computer and use it in GitHub Desktop.

Build a playable Super Mario Bros-style platformer game in a single HTML file using HTML5 canvas, CSS, and vanilla JavaScript โ€” no external libraries or assets. The final result must be clean, responsive, and fully self-contained (index.html only).

The game should capture the core mechanics and feel of the classic Mario platformer:


โœ… Core Gameplay Features

  • Player Movement

    • Smooth left/right movement with arrow keys or A/D
    • Jumping with Space or W
    • Gravity, momentum, and mid-air physics that feel like classic Mario
  • Platforms & Level Layout

    • Basic level design with ground tiles, floating platforms, gaps to jump across
    • Background (simple parallax or scrolling optional)
    • Put those floating bars in the sky as well like in a classic Mario game
  • Enemies (like Koopas)

    • Include roaming turtle-like enemies
    • If the player touches them from the side/front, they take damage or die
    • If the player jumps on top of them, the enemy is defeated
  • Collision Detection

    • Handle all collision logic cleanly: platforms, ground, ceilings, enemies
    • Ensure precise bounding boxes for both player and enemies
  • Scoring & HUD

    • Show player score and coins collected
    • Display number of lives
    • Optional: a simple timer (like in classic Mario)
  • Game States

    • Game Over screen when player runs out of lives or falls
    • Restart functionality
    • Optional: Level complete condition (e.g., reach the right side or a flag)

๐ŸŽฎ Controls

  • โ† โ†’ or A/D โ€” Move left/right
  • Space or W โ€” Jump
  • (Optional: R โ€” Restart game)

๐Ÿ’… Visual & UX Guidelines

  • Use Canvas to render all visuals โ€” tilemap, character, enemies, etc.
  • Style with embedded <style> and script inside <script> โ€” all in a single index.html
  • Pixel-style visuals (blocky tiles, 8-bit feel) are preferred
  • Use simple color fills, gradients, or inline SVG/CSS tricks to simulate sprite graphics
  • Include simple animations: walking cycle, enemy movement, player death

โœ… Deliverables

  • A single HTML file with all logic, styles, and game assets embedded
  • Functional game loop using requestAnimationFrame
  • Clean, readable, and commented JavaScript code
  • Fully playable and enjoyable browser experience โ€” no build steps or setup

Remember: this is a Mario-inspired clone, so aim for gameplay thatโ€™s fun, responsive, and nostalgic โ€” even with minimal graphics. Prioritize solid mechanics, working collision logic, and enemy behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment