Commit b3424b6e by BellCodeEditor

save project

parent d9c531de
Showing with 9 additions and 6 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
time=0
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3): def __init__(self,image1,image2,image3):
super().__init__() super().__init__()
...@@ -76,16 +76,19 @@ while True: ...@@ -76,16 +76,19 @@ while True:
time+=1 time+=1
if time>60: if time>60:
r=random.randint(0,100)
if r >40:
obstacle=Block(bush,cacti,stone)
block_list.add(obstacle)
time=0 time=0
num=random.randint(0,50)
if num >20:
obstacle=Block
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失 if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
aa.rect.x -= 8 aa.rect.x -= 8
for prop.rect.x<0-prop.rect.wigth:
prop.rect.x-=8
screen.bilt(prop.image,(prop.rect.x,prop.rect.y))
if prop.rect.x<=0-prop.rect.width:
prop.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