Commit 5d96c1e7 by BellCodeEditor

save project

parent 917c726c
Showing with 39 additions and 6 deletions
R-C.jpg

21.7 KB

......@@ -5,17 +5,49 @@ pygame.init()
b=pygame.image.load('bg.png')
c=pygame.image.load('body.png')
d=pygame.image.load('apple.png')
e=pygame.image.load('right.png')
# 创建一个窗口
right=pygame.image.load('right.png')
left=pygame.image.load('left.png')
up=pygame.image.load('up.png')
down=pygame.image.load('down.png')
a=pygame.display.set_mode((660,480))
x,y=240,120
e='right'
g=right
f=[(180,90),(180,120),(210,120),(x,y)]
fps=pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type==locals.QUIT:
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_DOWN and e!='up':
e='down'
g=down
if event.key==locals.K_UP and e!='down':
e='up'
g=up
if event.key==locals.K_LEFT and e!='right':
e='left'
g=left
if event.key==locals.K_RIGHT and e!='left':
e='right'
g=right
if e == 'right':
x+=30
if e == 'left':
x-=30
if e == 'up':
y-=30
if e == 'down':
y+=30
f.append((x,y))
f.pop(0)
a.blit(b,(0,0))
a.blit(e,(240,120))
a.blit(d,(360,300))
a.blit(c,(210,120))
a.blit(c,(180,120))
a.blit(c,(180,90))
a.blit(g,(f[-1]))
for i in range(len(f)-1):
a.blit(c,f[i])
fps.tick(7)
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