Commit f89a8c8b by BellCodeEditor

save project

parent 3d45efb7
Showing with 13 additions and 1 deletions
...@@ -28,18 +28,30 @@ while True: ...@@ -28,18 +28,30 @@ while True:
if event.type==locals.KEYDOWN: if event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT and R!='left': if event.key==locals.K_RIGHT and R!='left':
R='right' R='right'
r=right
if event.key==locals.K_LEFT and R!='right': if event.key==locals.K_LEFT and R!='right':
R='left' R='left'
r=left
if event.key==locals.K_UP and R!='down': if event.key==locals.K_UP and R!='down':
R='up' R='up'
r=up
if event.key==locals.K_DOWN and R!='up': if event.key==locals.K_DOWN and R!='up':
R='down' R='down'
r=down
if R=='right':
x+=30
if R=='left':
x-=30
if R=='up':
y-=30
if R=='down':
y+=30
xy.pop(0) xy.pop(0)
xy.append((x,y)) xy.append((x,y))
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right,xy[-1]) screen.blit(r,xy[-1])
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(xy)-1): for i in range(len(xy)-1):
screen.blit(body, xy[i]) screen.blit(body, xy[i])
......
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