Commit 32f39f10 by BellCodeEditor

auto save

parent c6188a1e
Showing with 34 additions and 2 deletions

22.5 KB | W: | H:

6.93 KB | W: | H:

bg.png
bg.png
bg.png
bg.png
  • 2-up
  • Swipe
  • Onion skin

1.4 KB | W: | H:

663 Bytes | W: | H:

body.png
body.png
body.png
body.png
  • 2-up
  • Swipe
  • Onion skin
import pygame import pygame
from pygame import locals
# 初始化pygame,为使用pygame做准备 # 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
# 创建一个窗口 # 创建一个窗口
?? screen = pygame.display.set_mode((800,600))
\ No newline at end of file clock = pygame.time.Clock()#设置随机刻
#载入图片
bg = pygame.image.load('bg.png')
up = pygame.image.load('up.png')
body = pygame.image.load('body.png')
apple = pygame.image.load('apple.png')
x,y=240,360
position = [(240,360),(240,390),(240,420),(x,y)]#存储三个身体和蛇头的位置
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
y-=30
position.append((x,y))#把xy追加到列表末尾
position.pop(0)#删除列表第一项
#图片渲染
screen.blit(bg,(0,0))
screen.blit(up,position[-1])
for i in range(len(position)-1):
screen.blit(body,position[i])
screen.blit(apple,(0,30))#渲染苹果
pygame.display.update()#刷新画面
clock.tick(1)#控制随机刻
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