Commit 3a5c9edb by BellCodeEditor

auto save

parent 44c2b159
Showing with 44 additions and 19 deletions
import pygame import pygame
from pygame import locals from pygame import locals
# 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
bg=pygame.image.load('bg.png')
tou=pygame.image.load('right.png') s=pygame.display.set_mode((800,600))
pg=pygame.image.load('apple.png')
st=pygame.image.load('body.png') dg=pygame.image.load('bg.png')
st1=pygame.image.load('body.png') ri=pygame.image.load('right.png')
st2=pygame.image.load('body.png') ap=pygame.image.load('apple.png')
# 创建一个窗口 do=pygame.image.load('body.png')
screen=pygame.display.set_mode((800,600))
jsp=pygame.time.Clock()
x,y=240,210
shenti=[(150,180),(150,210),(180,210),(210,210),(x,y)]
chaoxiang='right'
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:
exit() exit()
screen.blit(bg,(0,0)) if event.type==locals.KEYDOWN:
screen.blit(tou,(0,0)) if event.key==locals.K_RIGHT:
screen.blit(pg,(120,360)) chaoxiang='right'
for c in range(0,801,30): if event.key==locals.K_LEFT:
for d in range(0,601,30): chaoxiang='left'
if event.key==locals.K_UP:
screen.blit(st,(c,d)) chaoxiang='up'
if event.key==locals.K_DOWN:
chaoxiang='down'
if chaoxiang=='right':
x+=30
if chaoxiang=='left':
x-=30
if chaoxiang=='up':
y-=30
if chaoxiang=='down':
y+=30
shenti.append((x,y))
shenti.pop(0)
s.blit(dg,(0,0))
s.blit(ri,(x,y))
for i in range(len(shenti)-1):
s.blit(do,shenti[i])
s.blit(ap,(33,33))
# s.blit(do,(240,210))
# s.blit(do,(210,210))
# s.blit(do,(180,180))
# s.blit(do,(180,210))
# s.blit(do,(180,150))
pygame.display.update() pygame.display.update()
jsp.tick(1)
\ 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