Skip to content

arson-diops/test-pong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Pong Game

A classic Pong game implemented in HTML5 Canvas and JavaScript. Play against an AI opponent using mouse controls.

Features

  • Mouse Controls: Control the left paddle with your mouse
  • AI Opponent: The right paddle is controlled by a simple AI
  • Score Tracking: Keep track of scores for both players
  • Collision Detection: Realistic ball physics with paddle collision
  • Responsive Design: Clean, dark-themed interface

How to Play

  1. Open index.html in your web browser
  2. Move your mouse up and down to control the left paddle
  3. Try to hit the ball past the AI opponent's paddle
  4. First to score wins!

Game Controls

  • Mouse Movement: Control left paddle position
  • The AI automatically controls the right paddle

Project Structure

├── index.html          # Main HTML file
├── script.js          # Game logic and mechanics
├── styles.css         # Styling and layout
├── README.md          # Project documentation
└── .vscode/
    └── launch.json    # VS Code debug configuration

Development

Running Locally

Simply open index.html in any modern web browser, or use the VS Code launch configurations:

  • Launch Microsoft Edge: Opens the game in Edge browser
  • Launch Edge Headless and attach DevTools: For debugging
  • Launch Edge and attach DevTools: For development with DevTools

Game Constants

Key game settings can be modified in script.js:

  • PADDLE_SPEED: How fast paddles move (default: 5)
  • BALL_SPEED: Initial ball velocity (default: 5)
  • PADDLE_WIDTH & PADDLE_HEIGHT: Paddle dimensions
  • Canvas size: 900x500 pixels

Technical Details

  • Built with vanilla JavaScript and HTML5 Canvas
  • Uses requestAnimationFrame for smooth 60fps gameplay
  • Implements basic physics for ball movement and collision
  • AI uses simple tracking algorithm to follow the ball

Browser Compatibility

Works in all modern browsers that support HTML5 Canvas:

  • Chrome/Edge
  • Firefox
  • Safari
  • Opera

License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published