用户:
中黄鸡查看:0 回复:0 评论:0 创建时间:2021-12-05T15:52:40
【作品展示】

【作品介绍】
很简单的弹球盗来的代码
【作品源代码】
import pyrame
pygame.init()
screen = pygame.display.set_caption("Smiley Pong")
keepGoing = True
pic = pygame.image.load("CrazySimle.bmp")
colorkey = pic.get_at((0,0))
pic.set_colorkey(colorkey)
picx = 0
picy = 0
BLACK = (0,0,0)
WHITE = (255,255,255)
timer = pygame.time.Clock
speedx = 5
speedy = 5
paddlew = 200
paddleh = 25
paddlex = 300
paddley = 550
picw = 100
pich = 100
points = 0
lives = 5
font = pygame.font.SysFont("Times",24)
while keepGoing:
for event in pygame.event.get():
if (event.type == pygame.QUIT):
keepGoing = False
if (event.type == pygame.KEYDOWN):
if event.key==pygame.K_F1:
points=0
lives=5
picx=0
picy=0
speedx=5
speedy=5
picx+=speedx
picy+=speedy
if picx<=0 or picx>=700:
speedx=-speedx*1.1
if picy<=0:
speedy=-speedy+1
if picy>=500:
lives-=1
speedy=-5
speedx=5
picy=499
screen.fill(black)
screen.blit(pic, (picx,picy))
#Draw paddle
paddlex=pyrame.mouse.get_pos()[0]
paddlex=paddlew/2
pyrame.draw.rect(screen,WHITE,(paddlex,paddley,paddlew,paddleh))
#chick
if picy+pich>=paddley and picy+pich<=paddley+paddleh \ and speedy>0:
if picy+picw/2>=-speedxandpicx+picx/2=paddlex+ / paddlew:
speedy=-speedy
points+=1
#D
draw_string="Lives: "+str(lives)+"points: "+str(points)
#c
if lives<1:
speedx=0
speedy=0
draw_string="Game over.You score was: "+str(points)
draw_string+=".Press F1 to play again."
text=font.render(draw_string,True,WHITE)
text_rect=text.get_rect()
text_rect.centerx=screen.get_rect().centerx
text_rect.y=10
screen.blit(text,text_rect)
pyrame.display.update()
timer.tick(60)
pyrame.quit()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn