Commit b49494b3 by BellCodeEditor

save project

parent b1b35771
Showing with 17 additions and 3 deletions
...@@ -33,7 +33,8 @@ y = 400 ...@@ -33,7 +33,8 @@ y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
time=0
block_list=pygame.sprite.Group()
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:
...@@ -43,7 +44,7 @@ while True: ...@@ -43,7 +44,7 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
if
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
...@@ -79,7 +80,20 @@ if ...@@ -79,7 +80,20 @@ if
# 创建障碍物对象 # 创建障碍物对象
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
aa.rect.x -= 8 aa.rect.x -= 8
time+=1
if time>=60:
r=random.randint(0,100)
if r>40:
obstacle=Block(bush,cacti,stone)
block_list.add(obstacle)
time=0
for aa in block_list:
aa.rect.x-+8
screen.blit(aa.image,(aa.rect.x,aa.rect.y))
if aa.rect.x<=0-aa.rect.width:
aa.kill()
screen.blit(aa.image, (aa.rect.x, aa.rect.y)) screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面 # 刷新画面
......
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