我试图在屏幕上制作多个平台(块),玩家可以在上面跳跃和降落。当我只保留一个方块时,玩家可以在上面跳跃并轻松落地,但当我创建其他平台时,玩家可以跳跃,它会被方块击中并在地图下方移动,但如果我尝试跳过其他平台,它会轻松落地
到目前为止我试过的
# Checking Collision of Platform and Hero
self.obstacleHit_or_not(self.hero, self.platform, 460)
self.obstacleHit_or_not(self.hero, self.platform1, 460)
# This function works for Blocks only
def obstacleHit_or_not(self, hero, platform, position):
hit = pygame.sprite.collide_rect(hero, platform)
if hit:
#print("ITS HITTING")
hero.y = position
elif self.hero.y == position:
#print("HITTING INSIDE OF 450")
while True:
hero.y += 5
if hero.y >= 625:
break
有人能帮我解决这个问题吗?我只想让我的玩家在我在屏幕上创建的每个方块上着陆。提前谢谢
目前没有回答
相关问题 更多 >
编程相关推荐