import pygame
import time
import random
# loading 加载 初始化
pygame.init() # 1.初始化游戏
screen = pygame.display.set_mode((600, 500)) # 设置窗口大小
pygame.display.set_caption("蔡旭坤大招乔碧落")
# 事件
ball_x = 300
ball_y = 250
rect_x, rect_y,rect_w,rect_h = 300,460,120,40
def ball(ball_x, ball_y):
pygame.draw.circle(screen, (255., 25, 52), (ball_x, ball_y), 20, 0)
while True: # 不断循环
for event in pygame.event.get():
print(event)
if event.type == pygame.QUIT: # 判断是否点击退出
pygame.quit()
screen.fill((34,177,135))# regb
ball_y = ball_y+33
if ball_y > 500:
ball_y = 0
ball_x = random.randint(0, 600)
ball(ball_x,ball_y)
# ball_x = ball_x+44
# if ball_x > 600:
# ball_x = 0
# for i in range(10,100,10):
# ball(ball_x+i, ball_y+i*10)
pygame.draw.rect(screen,(100,200,30),(rect_x, rect_y,rect_w,rect_h),0)
pygame.display.update() #刷新画面
time.sleep(0.1)
pygame.quit() # 2。退出游戏
# 游戏
# 操控游戏,判断输赢
# 添加图片
# bgm
Qiyuan-python接小球游戏
最新推荐文章于 2022-05-16 16:26:00 发布