Commit 04ee1487 by BellCodeEditor

save project

parent d3ad8ed7
Showing with 12 additions and 7 deletions
...@@ -2,26 +2,31 @@ import pygame ...@@ -2,26 +2,31 @@ import pygame
from pygame import locals from pygame import locals
pygame.init()#初始化pygame pygame.init()#初始化pygame
screen = pygame.display.set_mode((660,480))#创建窗口 screen = pygame.display.set_mode((660,480))#创建窗口
FPSCLOCK = pygame.time.Clock() FPSCLOCK = pygame.time.Clock()#设置计时器
#导入图片 #导入图片
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
apple = pygame.image.load('apple.png') apple = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
x = 210 x = 210#设置定量
y = 120 y = 120
weizhi = [(180,120),(150,120),(150,90),(x,y)]#创建列表
while True:#永久存在 while True:#永久存在
for event in pygame.event.get():#遍历pygame中的事件 for event in pygame.event.get():#遍历pygame中的事件
if event.type == locals.QUIT:#如果是退出事件,QUIT其实是一个常量,ctcl+鼠标点locals可以查看 if event.type == locals.QUIT:#如果是退出事件,QUIT其实是一个常量,ctcl+鼠标点locals可以查看
exit()#退出 exit()#退出
x += 30 x += 30
weizhi.append((x,y))#增加新坐标,是坐标不是索引
weizhi.pop(0)#删除旧坐标
#渲染图片,后为坐标,左上角为0,0,一小格左上角坐标为30的倍数 #渲染图片,后为坐标,左上角为0,0,一小格左上角坐标为30的倍数
screen.blit(background,(0,0)) screen.blit(background,(0,0))
screen.blit(right,(x,y)) screen.blit(right,(x,y))
screen.blit(apple,(30,30)) screen.blit(apple,(30,30))
screen.blit(body,(180,120)) for i in range(len(weizhi)-1):
screen.blit(body,(150,120)) screen.blit(body,weizhi[i])
screen.blit(body,(150,90)) #screen.blit(body,(180,120))
#screen.blit(body,(150,120))
#screen.blit(body,(150,90))
#刷新窗口 #刷新窗口
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(3)#控制帧数不超过3
\ No newline at end of file \ No newline at end of file
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