Commit 8baf804f by BellCodeEditor

save project

parent 90196acc
Showing with 93 additions and 96 deletions
......@@ -12,6 +12,14 @@ class Block(pygame.sprite.Sprite):
self.rect.x=1000
self.rect.y=500-self.rect.height
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
screen = pygame.display.set_mode((1000, 600),pygame.RESIZABLE)
FPS = pygame.time.Clock()
pygame.display.set_caption('酷跑')
......@@ -43,6 +51,7 @@ background_x=0
word2=0
nub1=0
nub =0
gamestate=True
y = 400
......@@ -56,103 +65,91 @@ while True:
if event.key == locals.K_SPACE:
jumpState = 'up'
if jumpState == 'up':
if JumpSpeed > 0:
y -= JumpSpeed
JumpSpeed-=2
else:
jumpState = 'down'
if jumpState == 'down':
if JumpSpeed <= 30:
y += JumpSpeed
JumpSpeed+=2
wukong = Player(hero[index])
if gamestate:
if jumpState == 'up':
if JumpSpeed > 0:
y -= JumpSpeed
JumpSpeed-=2
else:
jumpState = 'down'
if jumpState == 'down':
if JumpSpeed <= 30:
y += JumpSpeed
JumpSpeed+=2
else:
jumpState = 'runing'
JumpSpeed=30
y=400
if jumpState != 'up' and jumpState!='down':
index += 1
else:
jumpState = 'runing'
JumpSpeed=30
y=400
if jumpState != 'up' and jumpState!='down':
index += 1
else:
index =1
if index == 5:
index = 0
wukong = hero[index]
road_x-=8
if road_x==-1000:
road_x=0
background_x-=2
if background_x==-1000:
background_x=0
nub1+=1
if nub1==50:
word2+=1
nub1=0
rectNub=word2
if word2/2==int(word2/2):
nub=random.choice([1,2,3,4])
screen.blit(background, (background_x, 0))
screen.blit(road, (road_x,500))
screen.blit(wukong, (150,y))
scoreWord=word.render(info+str(word2),True,(255,255,255))
screen.blit(scoreWord, (730,10))
time+=1
if time==50:
time=0
r=random.randint(0,100)
if r>40:
o=Block(stone,cacti,apple)
block_list.add(o)
# for prop in block_list:
# prop.rect.x-=8
# screen.blit(prop.image,(prop.rect.x,prop.rect.y))
# if pygame.sprite.collide_rect(wukong,prop):
# break
# if prop.rect.x <= 0-prop.rect.width:
# prop.kill()
#if rectNub >= 9 and rect1.x<600 and rect1.x>300 and i==2:
# if rect2.x <= 0-rect2.width and nub==2:
# o2=random.choice([stone,cacti,apple])
# rect2=o2.get_rect()
# rect2.x=1000
# rect2.y=500-rect2.height
#rect2.x-=8
#if i==2:
# screen.blit(o2,(rect2.x,rect2.y))
# 刷新画面
pygame.display.update()
FPS.tick(50)
while 1:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE:
exit()
screen.blit(background,(0,0))
screen.blit(gameover,(400,100))
scoreWord2=word.render('按下空格键以继续',True,(255,255,255))
screen.blit(scoreWord2, (450,500))
scoreWord2=word.render('SCORES:'+str(word2),True,(0,0,0))
screen.blit(scoreWord2, (400,300))
pygame.display.update()
FPS.tick(50)
index =1
if index == 5:
index = 0
road_x-=8
if road_x==-1000:
road_x=0
background_x-=2
if background_x==-1000:
background_x=0
nub1+=1
if nub1==50:
word2+=1
nub1=0
rectNub=word2
if word2/2==int(word2/2):
nub=random.choice([1,2,3,4])
screen.blit(background, (background_x, 0))
screen.blit(road, (road_x,500))
screen.blit(wukong.image, (150,y))
scoreWord=word.render(info+str(word2),True,(255,255,255))
screen.blit(scoreWord, (730,10))
time+=1
if time==50:
time=0
r=random.randint(0,100)
if r>40:
o=Block(stone,cacti,apple)
block_list.add(o)
for prop in block_list:
prop.rect.x-=8
screen.blit(prop.image,(prop.rect.x,prop.rect.y))
if pygame.sprite.collide_rect(wukong,prop):
gamestate=
if prop.rect.x <= 0-prop.rect.width:
prop.kill()
#if rectNub >= 9 and rect1.x<600 and rect1.x>300 and i==2:
# if rect2.x <= 0-rect2.width and nub==2:
# o2=random.choice([stone,cacti,apple])
# rect2=o2.get_rect()
# rect2.x=1000
# rect2.y=500-rect2.height
#rect2.x-=8
#if i==2:
# screen.blit(o2,(rect2.x,rect2.y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
......
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