import pygame
import time
# 游戏初始化 loading 加载中
pygame.init()
# 设置游戏界面大小 dis 分开 play 玩 ----展览,展示
chuang_kou = pygame.display.set_mode((660,480))
# up上面 date日期 update升级
qiu_x = 100
qiu_y = 110
qiu_z = 55
qiu_r = 21
qiu_p = 190
qiu_c = 129
speed_y = 1
speed_x = 1
speed_r = 1
speed_z = 1
speed_p = 1
speed_c = 1
while 1 > 0:
# 鼠标 键盘
for jiankong in pygame.event.get():
print(jiankong)
# type 类型 QUIT 退出游戏
if jiankong.type == pygame.QUIT:
pygame.quit()
# 修改背景颜色 fill
chuang_kou.fill((31,111,91))
qiu_y = qiu_y + speed_y
qiu_x = qiu_x + speed_x
if qiu_y > 480:
speed_y = -1
elif qiu_y < 0:
speed_y = 1
if qiu_x>660:
speed_x = -1
elif qiu_x < 0:
speed_x = 1
qiu_r = qiu_r + speed_r
qiu_z = speed_z + qiu_z
if qiu_z > 660:
speed_z = -1
elif qiu_z < 0:
speed_z = 1
if qiu_r > 480:
speed_r = -1
elif qiu_r < 0:
speed_r = 1
qiu_p = qiu_p + speed_p
qiu_c = qiu_c + speed_c
if qiu_p > 660:
speed_p = -1
elif qiu_p < 0:
speed_p = 1
if qiu_c > 480:
speed_c = -1
elif qiu_c < 0:
speed_c = 1
# 画 draw 一个圆 circle:窗口,(r,g,b),(x,y),半径
pygame.draw.circle(chuang_kou,(204,222,111),(qiu_x,qiu_y),50)
pygame.draw.circle(chuang_kou,(171,221,211),(qiu_z,qiu_r),40)
pygame.draw.circle(chuang_kou,(32,23,51),(qiu_p,qiu_c),33)
# 画 draw 一个 长方形 rect:窗口,(r,g,b),(banx,bany,板长,板宽) # 三基色
pygame.draw.rect(chuang_kou,(222,111,66),(200,380,150,15))
pygame.display.update()
# CPU:负责计算
zhaowei -接小球游戏2.0
最新推荐文章于 2024-09-05 10:41:44 发布