# 🏓 Pong Game - Android
A classic Pong game built for Android using Kotlin and custom Canvas rendering.
## 📱 About
This is a single-player Pong game where you compete against an AI opponent. The game features smooth gameplay, collision detection, and score tracking.
## ✨ Features
- ✅ **Single Player vs AI** - Challenge the computer opponent
- ✅ **Touch Controls** - Drag anywhere on screen to move your paddle
- ✅ **Smart AI** - AI paddle tracks the ball with realistic delay
- ✅ **Score Tracking** - First to 5 points wins
- ✅ **Game Over Screen** - Shows winner and allows restart
- ✅ **Smooth 60 FPS** - Optimized game loop for fluid gameplay
- ✅ **Collision Physics** - Ball bounces realistically off paddles and walls
- ✅ **No External Libraries** - Built entirely with Android SDK
## 🎮 How to Play
1. **Launch the app** on your Android device
2. **Touch and drag** anywhere on the screen to move your paddle (left side)
3. **Hit the ball** back to the AI opponent
4. **Score points** when the ball passes the opponent's paddle
5. **First to 5 points wins!**
6. **Tap "TAP TO RESTART"** to play again
## 🛠️ Technical Details
### Architecture
The app follows a modular architecture with separated concerns:
├── MainActivity.kt # Entry point, lifecycle management ├── GameView.kt # Main game logic, rendering, input handling ├── GameThread.kt # Game loop running at 60 FPS ├── Paddle.kt # Paddle physics and movement └── Ball.kt # Ball physics, collision detection
### Key Components
- **Custom SurfaceView** - Hardware-accelerated rendering
- **Game Thread** - Dedicated thread for game loop
- **Canvas Drawing** - Direct 2D graphics rendering
- **Touch Input** - Responsive paddle control
- **Collision Detection** - AABB (Axis-Aligned Bounding Box) algorithm
## 📋 Requirements
- **Minimum SDK**: Android 7.0 (API 24)
- **Target SDK**: Android 14 (API 34)
- **Language**: Kotlin
- **Dependencies**:
- `androidx.core:core-ktx:1.12.0`
- `androidx.appcompat:appcompat:1.6.1`
## 🚀 Installation
### Option 1: Build from Source
1. **Clone the repository**
```bash
git clone https://github.com/yourusername/PongGame.git
cd PongGame
-
Open in Android Studio
- Launch Android Studio
- Select "Open an Existing Project"
- Navigate to the cloned directory
-
Sync and Build
- File → Sync Project with Gradle Files
- Build → Build APK
-
Run on Device
- Connect Android device via USB
- Enable Developer Options & USB Debugging
- Click ▶ Run
- Download the latest APK from Releases
- Enable "Install from Unknown Sources" on your device
- Open the APK file and install
PongGame/
├── app/
│ ├── build.gradle # Module-level dependencies
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml # App configuration
│ ├── java/com/example/ponggame/
│ │ ├── MainActivity.kt # Main activity
│ │ ├── GameView.kt # Game rendering & logic
│ │ ├── Paddle.kt # Paddle class
│ │ ├── Ball.kt # Ball class
│ │ └── GameThread.kt # Game loop thread
│ └── res/
│ ├── layout/
│ │ └── activity_main.xml
│ └── values/
│ └── themes.xml # App theme
├── build.gradle # Project-level build config
└── settings.gradle # Project settings
- Base Speed: 15 pixels/frame
- Speed Increase: 10% per paddle hit (max 25 pixels/frame)
- Spin Effect: Ball angle changes based on paddle hit position
- Wall Bounce: Perfect elastic collision with top/bottom walls
- Tracking Speed: 8 pixels/frame
- Target: Ball's Y position
- Difficulty: Designed to be challenging but beatable
- Win Condition: First player to reach 5 points
- Point Award: When ball passes opponent's side
- Ball Reset: Returns to center after each point
- None currently reported
Potential features for future versions:
- Difficulty levels (Easy/Medium/Hard)
- Two-player mode (Bluetooth/WiFi)
- Sound effects and background music
- Power-ups (faster ball, larger paddle, etc.)
- High score tracking
- Customizable paddle/ball colors
- Landscape orientation support
- Particle effects
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Commit your changes
git commit -m 'Add some AmazingFeature' - Push to the branch
git push origin feature/AmazingFeature
- Open a Pull Request
This project is licensed under the MIT License - see below for details:
MIT License
Copyright (c) 2024 [RevaRock]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[K.Revanth Sai Pavan Kumar]
- GitHub: RevaRock
- Email: k.revanth543@gmail.com
- Inspired by the classic Atari Pong (1972)
- Built as a learning project for Android game development
- Thanks to the Android developer community for documentation and resources
Coming soon...
./gradlew assembleRelease./gradlew testThis project follows the Kotlin Coding Conventions
Enjoy the game! 🏓
If you encounter any bugs or have suggestions, please open an issue.
---
## 📝 Customization Instructions
Before pushing to GitHub, replace these placeholders:
1. **Repository URL**: Replace `RevaRock` with your GitHub username
- Line 30: Clone URL
- Line 43: Releases link
- Line 152: Author GitHub link
2. **Author Information** (Lines 151-153):
```markdown
**[K.Revanth Sai Pavan Kumar]**
- GitHub: [@RevaRock](https://github.com/RevaRock)
- Email: k.revanth543@gmail.com
-
Copyright Year (Line 113):
Copyright (c) 2026 [K.Revanth Sai Pavan Kumar] -
Optional: Add screenshots to the Screenshots section once you have the app running
This README includes:
- ✅ Clear project description
- ✅ Feature list
- ✅ Installation instructions
- ✅ Project structure
- ✅ Technical details
- ✅ Contributing guidelines
- ✅ MIT License
- ✅ Professional formatting with emojis