Commit 904e88e6 by BellCodeEditor

auto save

parent 36ecbf1d
Showing with 55 additions and 7 deletions
a=int(input("aaa"))
b=0
while True:
if a%2==0:
a=a//2
else:
a=a*3+1
b+=1
if a==1:
break
print(b)
import pygame
import random
from pygame import locals
pygame.init() # 初始化
......@@ -9,29 +10,63 @@ FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
stone = [pygame.image.load('stone.png'), # 石头
pygame.image.load('cacti.png'), # 仙人掌
pygame.image.load('bush.png') ] # 灌木丛
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')]
index = 0
y=400
t=30 # 上升的初始值 初始速度
wukong='runing'
ww=stone[0]#设置初始障碍物
zx=1000 #设置障碍物的x坐标
zy=500-ww.get_rect().height #设置障碍物的y坐标
#print(.width,apple.get_rect().height)
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 and wukong=='runing':
wukong='up'
if wukong=='up': #上升的时候速度一直减少
if t>0:
y-=t #设置角色的高度
t-=2
else:
wukong='down' #最高点的时候设置状态为下降
if wukong=='down':
if t<=30:
y+=t
t+=2
else:
wukong='runing'
t=30
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero[index], (150, 400))
index+=1
if index==5:
screen.blit(hero[index], (150, y))
if wukong=='runing':
index+=1
if index==5:
index=0
else:
index=0
#渲染障碍物
screen.blit(ww, (zx, zy))
zx-=8
if zx<=0-ww.get_rect().width :
ww=random.choice(stone)
zx=1000
zy=500-ww.get_rect().height
# 刷新画面
pygame.display.update()
FPS.tick(40)
\ 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