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! ๐
/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
- Player 1 (Left Paddle):
W
= Move UpS
= Move Down
- Player 2 (Right Paddle):
โ
(Arrow Up) = Move Upโ
(Arrow Down) = Move Down
-
Clone this repo
git clone [email protected]:zethu-mzulwini/mini-pong.git cd mini-pong
-
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.