Commit 2ec16a02 by BellCodeEditor

save project

parent e273e0b5
apple.png

2.05 KB

bg.png

22.5 KB

body.png

1.4 KB

down.png

2.01 KB

left.png

2.07 KB

File added
right.png

2.05 KB

import pygame
from pygame import locals
pygame.init()
backgroung = pygame.image.load("bg.png")
apple = pygame.image.load("apple.png")
right = pygame.image.load("right.png")
body = pygame.image.load("body.png")
# 初始化pygame,为使用pygame做准备
pygame.init()
# 创建一个窗口
pingmu = pygame.display.set_mode((660,480))
x=270
y=240
postion = [(210,240),(240,240),(x,y)]
fps = pygame.time.Clock()
while True:
for event in pygame.event.get():
#print(event)
if event.type == locals.QUIT:
exit()
x+=30
postion.append((x,y))
postion.pop(0)
pingmu.blit(backgroung,(0,0))
pingmu.blit(apple,(360,330))
pingmu.blit(right,(x,y))
for i in range(len(postion)-1):
pingmu.blit(body,(postion[i]))
#pingmu.blit(body,(240,240))
#pingmu.blit(body,(210,240))
pygame.display.update()
fps.tick(5)
\ No newline at end of file
up.png

2.05 KB

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