Commit 03264861 by BellCodeEditor

save project

parent 8cb2b0e2
Showing with 34 additions and 7 deletions
......@@ -4,20 +4,47 @@ pygame.init()
screen = pygame.display.set_mode((660, 480))
FPSC=pygame.time.Clock()
x,y=240,120
pos = [(180,90),(180,120),(210,120),(x,y)]
background = pygame.image.load('bg.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')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
SH="right"
s_h=right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
x+=30
if event.type == locals.KEYDOWN:
if event.key==locals.K_RIGHT and SH !="left":
SH="right"
s_h=right
if event.key==locals.K_RIGHT and SH !="right":
SH="left"
s_h=left
if event.key==locals.K_RIGHT and SH !="down":
SH="up"
s_h=up
if event.key==locals.K_RIGHT and SH !="up":
SH="down"
s_h=down
if SH=="right":
x=x+30
if SH=="left":
x=x-30
if SH=="up":
y=y-30
if SH=="down":
y=y+30
pos.append((x,y))
pos.pop(0)
screen.blit(background, (0, 0))
screen.blit(right, (240, 120))
screen.blit(body, (210, 120))
screen.blit(body, (180, 120))
screen.blit(body, (180, 90))
screen.blit(right, pos[-1])
for i in range(len(pos)-1):
screen.blit(body, pos[i])
screen.blit(food, (360, 300))
pygame.display.update()
FPSC=tick(3)
\ No newline at end of file
FPSC.tick(1)
\ 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