Commit 970532ce by BellCodeEditor

save project

parent e1a4ea99
Showing with 7 additions and 3 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
...@@ -55,12 +55,16 @@ while True: ...@@ -55,12 +55,16 @@ while True:
else: else:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
position.pop(0)
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
if x == apple_x and y == apple_y: if x == apple_x and y == apple_y:
apple_x = random.randint(0,660) apple_x = random.randint(0,660)
apple_y = random.randint(0,480) apple_y = random.randint(0,480)
screen.blit(snake_head, position[-1]) mun1 = random.randint(1,22)
mun2 = random.randint(1,16)
else:
position.pop(0)
screen.blit(snake_head, position[-1])
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body, position[i]) screen.blit(body, position[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