Commit d6695109 by BellCodeEditor

save project

parent 9e658f85
Showing with 18 additions and 5 deletions

46.1 KB | W: | H:

24 KB | W: | H:

bg.png
bg.png
bg.png
bg.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -16,19 +16,32 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材
background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体
blockxy = [1,1]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_a:
if blockxy[1] > 1:
blockxy[1] -= 1
elif event.key == locals.K_s:
if blockxy[0] < 25:
blockxy[0] += 1
elif event.key == locals.K_d:
if blockxy[1] < 15:
blockxy[1] += 1
# 将背景图画上去
screen.blit(background,(0,0))
pygame.draw.rect(screen,(random.randint(0,255),random.randint(0,255),random.randint(0,255)),(120,20,20,20),0)
pygame.draw.rect(screen,(random.randint(0,255),random.randint(0,255),random.randint(0,255)),(120,20,20,20),1)
pygame.draw.rect(screen,(random.randint(0,255),random.randint(0,255),random.randint(0,255)),(blockxy[1]*20-20,blockxy[0]*20-20,20,20),0)
pygame.draw.rect(screen,(random.randint(0,255),random.randint(0,255),random.randint(0,255)),(blockxy[1]*20-20,blockxy[0]*20-20,20,20),1)
# 得分
Score_text = font.render(str(score),True,(random.randint(0,255),random.randint(0,255),random.randint(0,255)))
screen.blit(Score_text,(350,70))
if score > 9999:
screen.blit(Score_text,(310,70))
else:
screen.blit(Score_text,(320,70))
score += 100
# 刷新画面
pygame.display.update()
clock.tick(FPS)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment