Commit 492fa2f4 by BellCodeEditor

save project

parent 57911d8c
Showing with 26 additions and 2 deletions
...@@ -15,17 +15,41 @@ screen=pygame.display.set_mode((660,480)) ...@@ -15,17 +15,41 @@ screen=pygame.display.set_mode((660,480))
FPS=pygame.time.Clock() FPS=pygame.time.Clock()
x,y=240,120 x,y=240,120
position=[(270,150),(270,120),(270,90),(240,90),(x,y)] position=[(270,150),(270,120),(270,90),(240,90),(x,y)]
heading='right'
head=right
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()
x+=30 if event.type==locals.KEYDOWN:
if event.key==locals.K_UP and heading!='down':
heading ='up'
head=up
if event.key ==locals.K_DOWN and heading!='up':
heading ='down'
head=down
if event.key ==locals.K_RIGHT and heading!='left':
heading ='right'
head=right
if event.key ==locals.K_LEFT and heading!='right':
heading ='left'
head=left
if heading =='up':
y-=30
elif heading =='down':
y+=30
elif heading=='left':
x-=30
else:
x+=30
position.append((x,y)) position.append((x,y))
position.pop(0) position.pop(0)
screen.blit(bg,(0,0)) screen.blit(bg,(0,0))
screen.blit(right,(x,y)) screen.blit(head,(x,y))
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body,position[i]) screen.blit(body,position[i])
#screen.blit(body,(a-30,120)) #screen.blit(body,(a-30,120))
......
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