Commit 359ef1c0 by BellCodeEditor

save project

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