Commit 8baf804f by BellCodeEditor

save project

parent 90196acc
Showing with 22 additions and 25 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,6 +65,8 @@ while True:
if event.key == locals.K_SPACE:
jumpState = 'up'
wukong = Player(hero[index])
if gamestate:
if jumpState == 'up':
if JumpSpeed > 0:
y -= JumpSpeed
......@@ -82,7 +93,7 @@ while True:
if index == 5:
index = 0
wukong = hero[index]
road_x-=8
......@@ -103,7 +114,7 @@ while True:
screen.blit(background, (background_x, 0))
screen.blit(road, (road_x,500))
screen.blit(wukong, (150,y))
screen.blit(wukong.image, (150,y))
scoreWord=word.render(info+str(word2),True,(255,255,255))
screen.blit(scoreWord, (730,10))
......@@ -115,13 +126,13 @@ while True:
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()
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:
......@@ -137,22 +148,8 @@ while True:
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)
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