Commit 43d259d6 by BellCodeEditor

auto save

parent 4f8c86f1
Showing with 53 additions and 7 deletions
dict_students={'李泽宽':{'数学':100,'语文':93,'英语':91},
'六个核桃':{'数学':90,'语文':92,'英语':94},
'李泓霖':{'数学':91,'语文':98,'英语':98}}
while True:
name=input("请输入要查找的名字")
if name=="q":
break
elif name in dict_students:
print(dict_students[name])
else:
print(dict_students[name])
...@@ -7,30 +7,61 @@ pygame.init() ...@@ -7,30 +7,61 @@ pygame.init()
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
x , y = 240 , 120 x , y = 240 , 120
fation = [(180,90),(180,120),(210,120),(x,y)]
FPS = pygame.time.Clock() FPS = pygame.time.Clock()
sething = 'left'
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
down = pygame.image.load('down.png')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
seth = left
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()
x += 1 if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and sething != 'left':
sething = 'right'
seth = right
if event.key == locals.K_LEFT and sething != 'right':
sething = 'left'
seth = left
if event.key == locals.K_UP and sething != 'up':
sething = 'down'
seth = up
if event.key == locals.K_DOWN and sething != 'down':
sething = 'up'
seth = down
if sething == 'left':
x -= 30
if sething == 'right':
x += 30
if sething == 'up':
y += 30
if sething == 'down':
y -= 30
fation.append((x,y))
fation.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right, (x,y))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
screen.blit(body, (x-30, y)) screen.blit(seth,(x,y))
screen.blit(body, (x-60, y)) for i in range(len(fation)-1):
screen.blit(body, (x-90, y)) screen.blit(body,fation[i])
# screen.blit(body, (x-30, y))
# screen.blit(body, (x-60, y))
# screen.blit(body, (x-90, y))
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(300) FPS.tick(3)
\ No newline at end of file \ 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