Commit 4ef47146 by BellCodeEditor

auto save

parent 022ec8df
def a1(num):
if num==1:
return 1
temp=a1(num-1)
return num+temp
a1_num = a1(100)
print(a1_num)
\ No newline at end of file
def peach(n):
if n==10:
return 1
num = (peach(n+1)+1)*2
return num
peach_num = peach(1)
print(peach_num)
\ No newline at end of file
def q1(n):
if n<=2:
return 1
elif n>2:
value = q1(n-1)+q1(n-2)
return value
result = q1(8)
print(result)
\ No newline at end of file
......@@ -11,19 +11,42 @@ road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
hero = pygame.image.load('hero1.png')
index = 0
hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
i = 0
js="runing"
y=400
js="runing"
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key==locals.K_SPACE:
js="up"
if js=="up":
if y>150:
y-=5
else:
js="down"
if js=="down":
if y<400:
y+=5
else:
js="runing"
wkong=hero[i]
i=i+1
if i==5:
i=0
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero, (150, 400))
screen.blit(wkong, (150, y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
FPS.tick(0)
\ 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