Commit 9d351ae3 by BellCodeEditor

save project

parent 941e7845
Showing with 3 additions and 6 deletions
import pygame
import random
from pygame import locals
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右
......@@ -21,10 +18,8 @@ ay=360
ax=360
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -52,8 +47,10 @@ while True:
y -= 30
else:
y += 30
position.append((x, y))
if ay=30*random.randint(0,21)
ax=30*random.randint(0,15)
else:
position.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
......
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