Skip to content

zethu-mzulwini/mini-pong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Mini Pong Game (HTML5 Canvas)

A simple Pong clone built with HTML5 <canvas>, vanilla JavaScript, and CSS.

This project demonstrates animation loops, event handling, and collision detection without any external libraries.

Perfect for learning canvas basics or extending into your own game! ๐Ÿš€


๐Ÿ“‚ Project Structure

/mini-pong/
โ”œโ”€โ”€ index.html    # Main HTML file, sets up canvas
โ”œโ”€โ”€ css/
  โ””โ”€โ”€ styles.css  # Page & canvas styling
โ””โ”€โ”€ js/
  โ””โ”€โ”€ game.js     # Core game logic (animation, input, collisions)
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md     # This file

๐Ÿ•น๏ธ Controls

  • Player 1 (Left Paddle):
    • W = Move Up
    • S = Move Down
  • Player 2 (Right Paddle):
    • โ†‘ (Arrow Up) = Move Up
    • โ†“ (Arrow Down) = Move Down

๐Ÿš€ Getting Started

  1. Clone this repo

    git clone [email protected]:zethu-mzulwini/mini-pong.git
    cd mini-pong
  2. Open in browser Simply double-click index.html or open it in your favorite browser. (No server required!)


๐Ÿงฉ How It Works

This game uses requestAnimationFrame for smooth animation, handles keyboard events for paddle movement and detects collisions with paddles and walls. The ball will be reset when it leaves the screen.


๐Ÿ”ง Extending the Game

Want to make it your own? Some easy extensions:

  • Add a score system (display text at the top for each player)
  • Add sound effects when ball hits paddles/walls
  • Increase ball speed after each rally
  • Add a simple AI opponent (auto-move right paddle)
  • Customize colors, paddle sizes, or ball shape

๐Ÿ“œ License

This project is released under the MIT License.

About

A demonstration of HTML5 canvas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •