Commit 5136ffbb by BellCodeEditor

save project

parent b2dd49ef
Showing with 23 additions and 4 deletions
...@@ -14,7 +14,9 @@ i=1#造型 #不要动 ...@@ -14,7 +14,9 @@ i=1#造型 #不要动
y=400#y值 #不要动 y=400#y值 #不要动
Status = "running"#状态 #不要动 Status = "running"#状态 #不要动
g = 30 #重力 g = 30 #重力
#不要动 road_x = 0
bg_x = 0
#不要动
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
...@@ -27,17 +29,22 @@ hero = [pygame.image.load('hero1.png'), ...@@ -27,17 +29,22 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
zhang_ai = random.choice([stone,cacti,bush]) zhang_ai = random.choice([stone,cacti,bush])
rect = zhang_ai.get_rect() rect = zhang_ai.get_rect()
rect.x=1000 rect.x=1000
rect.y = 500-rect.height rect.y = 500-rect.height
index = 0 index = 0
while True: #不要动 while True: #不要动
wukong = hero[i] #不要动 #不要动 #不要动#不要动#不要动#不要动#不要动#不要动#不要动 wukong = hero[i] #不要动 #不要动 #不要动#不要动#不要动#不要动#不要动#不要动#不要动
if Status == "running": #不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动 if Status == "running": #不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动
i = i+1 #不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动 i = i+1 #不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动#不要动
if i > 4: if i > 4:
i=0 i=0
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -47,12 +54,14 @@ while True: ...@@ -47,12 +54,14 @@ while True:
if Status == "running": if Status == "running":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
Status = "up" Status = "up"
if Status == "up": if Status == "up":
if g >= 0: if g >= 0:
y -= g y -= g
g -= 2 g -= 2
else: #不要动#不要动#不要动#不要动#不要动#不要动 else: #不要动#不要动#不要动#不要动#不要动#不要动
Status = "down" #不要动#不要动#不要动#不要动#不要动 Status = "down"
#不要动#不要动#不要动#不要动#不要动
if Status == "down": if Status == "down":
if g < 30: if g < 30:
y += g +2 y += g +2
...@@ -61,10 +70,20 @@ while True: ...@@ -61,10 +70,20 @@ while True:
Status = "running" Status = "running"
screen.blit(background, (0, 0))# 将背景图画上去 screen.blit(background, (bg_x, 0))# 将背景图画上去
screen.blit(road, (0, 500))# 将背景图画上去 #不要动#不要动#不要动#不要动#不要动 bg_x-=1#背景的移动
if bg_x<-1000:
bg_x=0
screen.blit(road, (road_x, 500))# 将路画上去
road_x-=8#路的移动
if road_x<-1000:
road_x=0
#不要动#不要动#不要动#不要动#不要动
screen.blit(wukong,(150,y))#悟空的动作 screen.blit(wukong,(150,y))#悟空的动作
#障碍:随机,移动
if rect.x <= 0-rect.width: if rect.x <= 0-rect.width:
zhang_ai = random.choice([stone,cacti,bush]) zhang_ai = random.choice([stone,cacti,bush])
rect = zhang_ai.get_rect() rect = zhang_ai.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