Commit 74c7f173 by BellCodeEditor

save project

parent c1d4bac7
Showing with 13 additions and 5 deletions
...@@ -2,6 +2,9 @@ import pygame ...@@ -2,6 +2,9 @@ import pygame
from pygame import locals from pygame import locals
x=240 x=240
y=120 y=120
sb=[(180,90),(180,120),(210,120),(x,y)]
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
...@@ -16,6 +19,8 @@ body = pygame.image.load('body.png') ...@@ -16,6 +19,8 @@ body = pygame.image.load('body.png')
FPSCLOCK=pygame.time.Clock() FPSCLOCK=pygame.time.Clock()
while True: while True:
x += 30 x += 30
sb.append((x,y))
sb.pop(0)
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
...@@ -25,11 +30,14 @@ while True: ...@@ -25,11 +30,14 @@ while True:
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right, (x, y)) screen.blit(right, (x, y))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
screen.blit(body, (210, 120)) for i in range(len(sb)-1):
screen.blit(body, (180, 120)) screen.blit(body,sb[i])
screen.blit(body, (180, 90)) # screen.blit(body, (210, 120))
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(2) FPSCLOCK.tick(2)
\ No newline at end of file
\ 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