Commit 47390c05 by BellCodeEditor

save project

parent 3db3fab9
Showing with 9 additions and 8 deletions
...@@ -35,7 +35,7 @@ class Block(pygame.sprite.Sprite): ...@@ -35,7 +35,7 @@ class Block(pygame.sprite.Sprite):
self.rect.x=1000 self.rect.x=1000
self.rect.y=500-self.rect.height self.rect.y=500-self.rect.height
obstacle=Block(bush,stone,cacti) obstacle=Block(bush,stone,cacti)
sprite_list=pygame.sprite.Group() block_list=pygame.sprite.Group()
time=0 time=0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -82,13 +82,13 @@ while True: ...@@ -82,13 +82,13 @@ while True:
time=0 time=0
num=random.randint(0,50) num=random.randint(0,50)
if num>20: if num>20:
obstacle=Block(bush,stone,cacti) print(11)
sprite_list.add(obstacle) obstacle=Block(bush,cacti,stone)
for sprite in sprite_list: print(22)
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x-=8 sprite.rect.x-=8
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y)) screen.blit(sprite.image, (sprite.rect.x,sprite.rect.y))
# if sprite.rect.x<0-sprite.rect.width: # 刷新画面
# sprite.kill()
刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ 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