用户:
01_DZY查看:0 回复:0 评论:0 创建时间:2022-04-07T09:07:11
【作品展示】

【作品介绍】
......
【作品源代码】
#
import pygame,random
from sys import exit
pygame.init()
#
scr = pygame.display.set_mode((956, 587))
pygame.display.set_caption("打陨石")
#
bj = pygame.image.load('C:\\Users\\donziyi\\Desktop\\dys\\bj py.png')
mz = pygame.image.load('C:\\Users\\donziyi\\Desktop\\dys\\mz py.png')
dq = pygame.image.load('C:\\Users\\donziyi\\Desktop\\dys\\dq py.png')
ys = pygame.image.load('C:\\Users\\donziyi\\Desktop\\dys\\ys py.png')
zx = pygame.image.load('C:\\Users\\donziyi\\Desktop\\dys\\zx py.png')
#
a, b = (50,50)
#
while True:
#
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
#
scr.blit(bj, (0, 0))
scr.blit(dq, (391, 206))
#
ys_rect = pygame.Rect(a, b, 50, 50)
scr.blit(ys,(ys_rect))
#
pygame.mouse.set_visible(False)
x, y = pygame.mouse.get_pos()
x -= mz.get_width() / 2
y -= mz.get_height() / 2
x1, y2 = pygame.mouse.get_pos()
x1 -= zx.get_width() / 2
y2 -= zx.get_height() / 2
zx_rect = pygame.Rect(x1, y2, 1, 1)
scr.blit(mz, (x, y))
scr.blit(zx, (zx_rect))
#
sj = zx_rect.colliderect(ys_rect)
if event.type == pygame.MOUSEBUTTONDOWN:
if sj == True:
print('射中了!')
a = random.randint(1, 906)
b = random.randint(1, 537)
else:
print('没射中!')
#
pygame.display.update()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn