Commit fa0523e2 by BellCodeEditor

save project

parent dbdc8693
Showing with 8 additions and 3 deletions
import pygame
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -14,6 +14,8 @@ up = pygame.image.load('up.png')
left = pygame.image.load('left.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
dx=300
dy=300
x=240
y=120
f=pygame.time.Clock()
......@@ -52,11 +54,13 @@ while True:
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(right,l[-1])
if x==dx and y==dy:
dx=dx.random(0,360)
dy=dy.random(0,300)
for i in range(len(l)-1):
screen.blit(body,l[i])
# 将果实画上去
screen.blit(food, (360, 300))
screen.blit(food, (dx, dy))
f.tick(4)
# 刷新画面
pygame.display.update()
\ No newline at end of file
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