merge local and remote repo

This commit is contained in:
Frank
2026-06-17 14:46:36 +08:00
2 changed files with 16 additions and 0 deletions

View File

@@ -1,7 +1,11 @@
# Ping Pong Game # Ping Pong Game
This ping_pong game made by frank This ping_pong game made by frank
<<<<<<< HEAD
![Game Cover](https://api.yppp.net/pc.php) ![Game Cover](https://api.yppp.net/pc.php)
=======
![Game Cover](https://cocktailhourentertainment.com/wp-content/uploads/2022/07/atari-pong-arcade-1920x1080-3.jpg)
>>>>>>> 2d13872febf768c59aec106182ed404dbbf57614
## Setup & Run ## Setup & Run
Install the required dependency and start the game with the following commands: Install the required dependency and start the game with the following commands:

12
main.py
View File

@@ -1,9 +1,12 @@
import pgzrun import pgzrun
<<<<<<< HEAD
import random import random
#随机数生成 #随机数生成
random_intX = random.randint(235, 1685) random_intX = random.randint(235, 1685)
random_intY = random.randint(235, 845) random_intY = random.randint(235, 845)
=======
>>>>>>> 2d13872febf768c59aec106182ed404dbbf57614
music.play('bgm') music.play('bgm')
# 窗口参数 # 窗口参数
@@ -21,11 +24,14 @@ paddle2 = Actor("2")
paddle2.x = WIDTH - 80 paddle2.x = WIDTH - 80
paddle2.y = HEIGHT / 2 paddle2.y = HEIGHT / 2
<<<<<<< HEAD
#box生成 #box生成
tbox = Actor("t_box") tbox = Actor("t_box")
tbox.x = random_intX tbox.x = random_intX
tbox.y = HEIGHT / 2 tbox.y = HEIGHT / 2
=======
>>>>>>> 2d13872febf768c59aec106182ed404dbbf57614
# 乒乓球 # 乒乓球
ball = Actor("ball") ball = Actor("ball")
ball.pos = (WIDTH//2, HEIGHT//2) ball.pos = (WIDTH//2, HEIGHT//2)
@@ -49,7 +55,10 @@ def draw():
paddle1.draw() paddle1.draw()
paddle2.draw() paddle2.draw()
ball.draw() ball.draw()
<<<<<<< HEAD
tbox.draw() tbox.draw()
=======
>>>>>>> 2d13872febf768c59aec106182ed404dbbf57614
# 游戏结束提示 # 游戏结束提示
if game_state == "gameover": if game_state == "gameover":
@@ -85,6 +94,7 @@ def update():
if ball.colliderect(paddle1) or ball.colliderect(paddle2): if ball.colliderect(paddle1) or ball.colliderect(paddle2):
ball_speed_x *= -1 ball_speed_x *= -1
sounds.bump.play() sounds.bump.play()
<<<<<<< HEAD
#方块实现 #方块实现
if ball.colliderect(tbox): if ball.colliderect(tbox):
sounds.bump.play() sounds.bump.play()
@@ -103,6 +113,8 @@ def update():
random_intY = random.randint(235, 845) random_intY = random.randint(235, 845)
tbox.x = random_intX tbox.x = random_intX
tbox.y = random_intY tbox.y = random_intY
=======
>>>>>>> 2d13872febf768c59aec106182ed404dbbf57614
# 出左右边界直接失败 # 出左右边界直接失败
if ball.left <= 0: if ball.left <= 0: