diff --git a/apple.png b/apple.png new file mode 100644 index 0000000..e58cb8f Binary files /dev/null and b/apple.png differ diff --git a/bg.png b/bg.png new file mode 100644 index 0000000..a085237 Binary files /dev/null and b/bg.png differ diff --git a/body.png b/body.png new file mode 100644 index 0000000..a254609 Binary files /dev/null and b/body.png differ diff --git a/down.png b/down.png new file mode 100644 index 0000000..41d1525 Binary files /dev/null and b/down.png differ diff --git a/left.png b/left.png new file mode 100644 index 0000000..365dffe Binary files /dev/null and b/left.png differ diff --git a/neuropol.ttf b/neuropol.ttf new file mode 100644 index 0000000..ddefb40 Binary files /dev/null and b/neuropol.ttf differ diff --git a/right.png b/right.png new file mode 100644 index 0000000..e77639a Binary files /dev/null and b/right.png differ diff --git a/snake.py b/snake.py new file mode 100644 index 0000000..9f007b6 --- /dev/null +++ b/snake.py @@ -0,0 +1,52 @@ +import pygame +from pygame import locals + +# 初始化pygame,为使用硬件做准备 +pygame.init() + +# 创建一个窗口 +screen = pygame.display.set_mode((660, 480)) + +# 背景 +background = pygame.image.load('bg.png') +right = pygame.image.load('right.png') +food = pygame.image.load('apple.png') +body = pygame.image.load('body.png') + +while True: + for event in pygame.event.get(): + if event.type == locals.QUIT: + # 接收到退出事件后退出程序 + exit() + # 将背景图画上去 + 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(food, (360, 300)) + # 刷新画面 + pygame.display.update() +Time=pygame.time.Clock() + + +while True: + for event in pygame.event.get(): + if event.type == locals.QUIT: + exit() + + + screen.blit(background,(0,0)) + screen.blit(right(x,y)) + list.append((x,y)) + list.pop(0) + screen.blit(right,list[-1]) + screen.blit(food,(apple_x,apple_y)) + for i in range(len(list)-1): + screen.bilt(body,list[i]) + + + \ No newline at end of file diff --git a/up.png b/up.png new file mode 100644 index 0000000..44f2e28 Binary files /dev/null and b/up.png differ