Commit 1b65d2d3 by BellCodeEditor

auto save

parent 30e91309
Showing with 0 additions and 32 deletions
import pygame import pygame
from pygame import locals
# 初始化pygame,为使用pygame做准备 # 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((800,600))
#载入图片
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
apple = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
#设置计时器
FPSCLOCK = pygame.time.Clock()
#设置蛇头初始位置
x , y = 210 , 150
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
x += 30
#图片渲染
screen.blit(background,(0,0))
screen.blit(right,(x,y))
screen.blit(apple,(390,300))
screen.blit(body,(180,150))
screen.blit(body,(150,150))
screen.blit(body,(120,150))
#刷新窗口
pygame.display.update()
#窗口刷新频率,数值越大越快
FPSCLOCK.tick(3)
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