Commit 480699af by BellCodeEditor

save project

parent 5b0b4624
Showing with 11 additions and 5 deletions
...@@ -38,7 +38,7 @@ y = 400 ...@@ -38,7 +38,7 @@ y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
blocklist=pygame.sprite.Group() blocklist=pygame.sprite.Group()
time=0
dl=0 dl=0
bj=0 bj=0
while True: while True:
...@@ -81,14 +81,19 @@ while True: ...@@ -81,14 +81,19 @@ while True:
dl=0 # 远处背景 dl=0 # 远处背景
screen.blit(road, (dl, 500)) # 路 screen.blit(road, (dl, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
time+=1
obstacle = Block(bush,stone,cacti) if time>=60:
time=0
num=random.randint(0,50)
if num>30:
obstacle=Block(bush,stone,cacti)
blocklist.add(obstacle) blocklist.add(obstacle)
for i in blocklist: for i in blocklist:
i.rect.x-=8 i.rect.x-=8
screen.blit(i.image, (i.rect.x,i.rect.y)) screen.blit(i.image, (i.rect.x,i.rect.y))
if i.rect.x<0-i.rect.width:
screen.blit(obstacle.image, ( obstacle.rect.x, obstacle.rect.y)) i.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