Commit 08f0f3d4 by BellCodeEditor

save project

parent f4cdd193
Showing with 7 additions and 5 deletions
...@@ -4,6 +4,10 @@ from pygame import locals ...@@ -4,6 +4,10 @@ from pygame import locals
# 初始化pygame,为使用pygame做准备 # 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
#创建一个窗口
screen = pygame.display.set_mode((660,480))
FPSCLOCK = pygame.time.Clock() #pygame时钟,控制游戏速度(帧数)
#载入图片 #载入图片
background = pygame.image.load('bg.png') #背景图 background = pygame.image.load('bg.png') #背景图
right = pygame.image.load('right.png') #头 朝右 right = pygame.image.load('right.png') #头 朝右
...@@ -12,9 +16,6 @@ body = pygame.image.load('body.png') ...@@ -12,9 +16,6 @@ body = pygame.image.load('body.png')
x,y = 240,120 #初始化贪吃蛇的头的坐标 x,y = 240,120 #初始化贪吃蛇的头的坐标
# 创建一个窗口
screen=pygame.display.set_mode((660,480))
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -32,4 +33,5 @@ while True: ...@@ -32,4 +33,5 @@ while True:
#将苹果画上去 #将苹果画上去
screen.blit(food,(360,300)) screen.blit(food,(360,300))
#刷新画面 #刷新画面
pygame.display.update() pygame.display.update()
\ No newline at end of file FPSCLOCK.tick(3)
\ 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