Commit 359ef1c0 by BellCodeEditor

save project

parent cd2d6fd9
Showing with 29 additions and 10 deletions
...@@ -37,11 +37,19 @@ class Rsc(pygame.sprite.Sprite): ...@@ -37,11 +37,19 @@ class Rsc(pygame.sprite.Sprite):
self.rect=self.image.get_rect() self.rect=self.image.get_rect()
self.rect.x=1000 self.rect.x=1000
self.rect.y=500-self.rect.height self.rect.y=500-self.rect.height
obg=Rsc(stone,cacti,apple) class Player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
#obg=Rsc(stone,cacti,apple)
blist=pygame.sprite.Group() blist=pygame.sprite.Group()
while True: while True:
print(G) print(PS)
time+=1 time+=1
if time>=60: if time>=60:
a=randint(1,60) a=randint(1,60)
...@@ -80,18 +88,23 @@ while True: ...@@ -80,18 +88,23 @@ while True:
if IM=='up': if IM=='up':
if y>150: if y>150:
y-=2*G y-=2*G
y=wukon.rect.y
G-=0.1 G-=0.1
else: else:
IM='down' IM='down'
if IM=='dup': if IM=='dup':
y=wukon.rect.y
if G>=0: if G>=0:
y-=G y-=G
y=wukon.rect.y
G-=0.15 G-=0.15
else: else:
IM='down' IM='down'
if IM=='down': if IM=='down':
y=wukon.rect.y
if y<=400: if y<=400:
y+=2*G y+=2*G
y=wukon.rect.y
G+=0.2 G+=0.2
else: else:
G=5 G=5
...@@ -99,7 +112,8 @@ while True: ...@@ -99,7 +112,8 @@ while True:
y=400 y=400
if IM!='up': if IM!='up':
IM='running' IM='running'
herorun=hero[index] #herorun=hero[index]
wukon=Player(hero[index])
# 将背景图画上去 # 将背景图画上去
bg_x-=1 bg_x-=1
...@@ -110,13 +124,18 @@ while True: ...@@ -110,13 +124,18 @@ while True:
if rond_x<= -1000: if rond_x<= -1000:
rond_x=0 rond_x=0
screen.blit(road, (rond_x, 500)) screen.blit(road, (rond_x, 500))
screen.blit(herorun, (150, y)) screen.blit(wukon.image, (150, y))
# if obg.rect.x<0-obg.rect.height:
# obg=Rsc(stone,cacti,apple) # obg=Rsc(stone,cacti,apple)
for pop in blist: for sprite in blist:
pop.rect.x-=8 sprite.rect.x-=8
screen.blit(pop.image,(pop.rect.x,pop.rect.y)) screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x<0-sprite.rect.height:
sprite.kill()
if pygame.sprite.collide_rect(wukon,sprite):
gameover=pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
# gamestate=False
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
PS+=1 PS+=1
FPS.tick(PS) FPS.tick(60)
\ No newline at end of file \ 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