Commit 8562f44c by BellCodeEditor

save project

parent fb9a9b35
apple.png

2.05 KB

bg.png

22.5 KB

body.png

1.4 KB

down.png

2.01 KB

left.png

2.07 KB

File added
import pygame
from pygame import locals
pygame.init()
a=pygame.display.set_mode((660,480))
b=pygame.image.load('bg.png')
c=pygame.image.load('right.png')
d=pygame.image.load('body.png')
e=pygame.image.load('body.png')
f=pygame.image.load('body.png')
g=pygame.image.load('body.png')
e=pygame.image.load('apple.png')
x,y=210,120
list=[(150,90),(150,120),(180,120),(x,y)]
p=pygame.time.Clock()
shetou='right'
while True:
for event in pygame.event.get():
print(event)
if event.type== locals.QUIT:
exit()
if event.type== locals.KEYDOWN:
if event.key== locals.K_RIGHT and shetou != 'left':
shetou='right'
if event.key== locals.K_LEFT and shetou != 'right':
shetou='left'
if event.key== locals.K_UP and shetou != 'down':
shetou='up'
if event.key== locals.K_DOWN and shetou != 'UP':
shetou='down'
if shetou=='right':
x+=30
if shetou=='left':
x-=30
if shetou=='down':
y+=30
if shetou=='up':
y-=30
list.append((x,y))
list.pop(0)
a.blit(b,(0,0))
a.blit(c,(x,y))
a.blit(d,list[3])
a.blit(d,list[2])
a.blit(e,list[1])
a.blit(f,list[0])
a.blit(g,(300,180))
pygame.display.update()
p.tick(20)
\ No newline at end of file
right.png

2.05 KB

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