Commit f52aa511 by BellCodeEditor

auto save

parent 15ec5fbf
Showing with 50 additions and 4 deletions
......@@ -4,9 +4,50 @@ from pygame import locals
pygame.init() #pygame初始化
screen = pygame.display.set_mode((660,480)) #创建游戏窗口
fpsclock = pygame.time.Clock()
background = pygame.image.load('bg.png') #载入背景图片
food = pygame.image.load('apple.png')
right = pygame.image.load('right.png')
body = pygame.image.load('body.png')
setheading = 'right'
x , y = 13*30 , 9*30
position = [(9*30,8*30),(9*30,9*30),(10*30,9*30),(x,y)]
while True:
for event in pygame.event.get():
print(event)
if event.type == locals.QUIT:
exit()
\ No newline at end of file
print(event) #窗口监听测试
if event.type == locals.QUIT: #利用locals库简介监听类型
exit()
if event.type == locals.KEYDOWN:
if event.type == locals.K_UP and setheading != 'down':
setheading = 'up'
print("wwwwww")
# if event.type == locals.K_DOWN and setheading != 'up':
# setheading = 'down'
# if event.type == locals.K_RIGHT and setheading != 'left':
# setheading = 'right'
# if event.type == locals.K_LEFT and setheading != 'right':
# setheading = 'left'
position.append((x,y)) #利用列表排布坐标
position.pop(0)
if setheading == 'right':
x+=30
# elif setheading == 'left':
# x-=30
# elif setheading == 'up':
# y-=30
else:
y+=30
screen.blit(background,(0,0)) #将图片资源布置到窗口中
screen.blit(right,position[-1])
for i in range(len(position)-1):
screen.blit(body,position[i])
screen.blit(food,(13*30,9*30))
pygame.display.update() #刷新窗口
fpsclock.tick(3)
\ No newline at end of file
test=[1,2,3,4,5]
test.append(6)
test.pop(0)
print(test)
\ 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