Commit 41af58d4 by BellCodeEditor

save project

parent 9f655d95
Showing with 31 additions and 5 deletions
...@@ -5,21 +5,46 @@ screen = pygame.display.set_mode((660, 480)) ...@@ -5,21 +5,46 @@ screen = pygame.display.set_mode((660, 480))
e=pygame.time.Clock() e=pygame.time.Clock()
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = 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')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
zx='right'
cx=right
x,y=240,120 x,y=240,120
lb=[(180,90),(180,120),(210,120),(x,y)] lb=[(180,90),(180,120),(210,120),(x,y)]
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
elif event.type == locals.KEYDOWN:
if event.key == locals.K_UP and zx != 'down':
zx='up'
cx=up
if event.key == locals.K_DOWN and zx != 'up':
zx='down'
cx=down
if event.key == locals.K_LEFT and zx != 'right':
zx='left'
cx=left
if event.key == locals.K_RIGHT and zx != 'left':
zx='right'
cx=right
if zx == 'right':
x+=30
elif zx == 'left':
x-=30
elif zx == 'up':
y-=30
else:
y+=30
lb.append((x,y))
lb.pop(0)
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(right, (x, y)) screen.blit(cx, (x, y))
for i in range(len(lb)-1): for i in range(len(lb)-1):
screen.blit(body,lb[i]) screen.blit(body,lb[i])
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
x+=30
lb.append((x,y))
lb.pop(0)
pygame.display.update() pygame.display.update()
e.tick(3) e.tick(3)
\ No newline at end of file
import random
import random
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