https://github.com/andreiextr/ping-pong
https://github.com/andreiextr/ping-pong
game
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/andreiextr/ping-pong
- Owner: AndreiExtr
- Created: 2023-08-10T20:12:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-10T20:25:58.000Z (almost 3 years ago)
- Last Synced: 2025-01-09T09:49:15.485Z (over 1 year ago)
- Topics: game
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ping-Pong
## The rule of the game:
+ Score 10 points
+ Reflect the ball with a strip
+ When the ball collides, the strip decreases

## The main code is "Reducing the strip when hitting the ball"
```
if
(
ballY + ball.clientHeight > paddle.offsetTop &&
ballX + ball.clientWidth > paddleX &&
ballX < paddleX + paddle.clientWidth
) {
ballSpeedY = -ballSpeedY;
score++;
scoreDisplay.textContent = score;
// Уменьшаем ширину полоски при ударе мячика
paddleWidth = Math.max(paddleWidth - 7, 7);
paddle.style.width = paddleWidth + "px";
}
```
[See demo](https://andreiextr.github.io/Ping-Pong/)