Commit 1fde446e by BellCodeEditor

save project

parent b6278a34
Showing with 26 additions and 8 deletions
......@@ -10,6 +10,15 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
y=400
class Block2(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
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
zaw_list=pygame.sprite.Group()
......@@ -29,15 +38,15 @@ pygame.display.set_caption('悟空酷跑')
a=0
t=30
zaw=Block(stone,cacti,apple)
wukong_1=hero[0]
wukong_1=Block2(hero[0])
wukong='running'
y=400
#z=random.choice([stone,cacti,apple])
#rect=stone.get_rect()
#z_x=1000
time=0
road_x=0
bg_x=0
gameover=False
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -46,30 +55,35 @@ while True:
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE and wukong=='running':
wukong='up'
if gameover==False:
if wukong=='running':
wukong_1=Block2(hero[a])
a+=1
if a>=5:
a=0
if wukong=='up':
if t>0:
y-=t
wukong_1.rect.y=y
t-=2
else:
wukong='down'
if wukong=='down':
if t<=30:
y+=t
wukong_1.rect.y=y
t+=2
else:
wukong='running'
t=30
#y=400
if wukong=='running':
wukong_1=hero[a]
a+=1
if a>=5:
a=0
# 将背景图画上去
screen.blit(background, (bg_x, 0))
screen.blit(road, (road_x, 500))
screen.blit(wukong_1, (150, y))
screen.blit(wukong_1.image, (150, y))
#z_x-=8
road_x-=8
......@@ -87,6 +101,10 @@ while True:
screen.blit(i.image, (i.rect.x, 500-i.rect.height))
if i.rect.x<=0-i.rect.width:
i.kill()
if pygame.sprite.collide_rect(wukong_1,i):
gmover=pygame.image.load('gameover.png')
screen.blit(gmover,(400,250))
gameover=True
#z=random.choice([stone,cacti,apple])
#rect=stone.get_rect()
......
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