Commit 99ccecfb by BellCodeEditor

save project

parent ee72422e
Showing with 32 additions and 3 deletions
import pygame
pygame.init()
screen=pygame.display.set_mode((660,480)) #创建一个660*480的窗口
from pygame import locals
pygame.init() #初始化pygame
screen=pygame.display.set_mode((660,480)) #创建一个660*480的窗口
FPSCLOCK=pygame.time.Clock() #控制游戏速度
#背景
background=pygame.image.load("bg.png") #将图片"bg.png"导入到图片中
apple=pygame.image.load("apple.png")
head=pygame.image.load("right.png")
body=pygame.image.load("body.png")
#头的坐标
x,y=(240,120)
position=[(180,90),(180,120),(210,120),(x,y)]
while True:
for event in pygame.event.get(): #遍历/监听
#退出程序
if event.type==locals.QUIT:
exit() #停止游戏
x+=30
position.append((x,y))
position.pop(0)
screen.blit(background,(0,0)) #渲染图片
screen.blit(apple,(600,60))
screen.blit(head,(x,y))
for i in range(len(position)-1):
screen.blit(body,position[i])
#screen.blit(body,(210,120))
#screen.blit(body,(180,120))
#screen.blit(body,(180,90))
#刷新页面
pygame.display.update()
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