当站在酸液上时试图让玩家摔倒

2024-09-29 01:37:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用pygame做一个platformer游戏,我被困在一个地方,当玩家站在酸性瓷砖上时,应该会摔倒,但我总是出错。 下面是检查以下各项的代码:

def update(self, deltatime):
    if not self.isShooting:
        pass

    self.image.update(deltatime)
    self.rect = self.image.getScaledImage(self.scale).get_rect()
    self.mask = pygame.mask.from_surface(self.image.getScaledImage(self.scale))
    self.rect.x = 200

    if self.isJumping or self.isFalling:
        self.y += self.jumpVelocity * (deltatime / 1000.0)
        self.jumpVelocity += self.jumpAcceleration * (deltatime / 1000.0)

        if self.jumpVelocity > 0 and self.image != self.jump:
            self.image = self.fall
        elif self.jumpVelocity < 0 :
            self.image = self.jump

    if self.isSliding:
        self.image = self.slide

    if self.y < ground:
        self.isFalling = True
        self.isJumping = False

    t = Tile(ground)
    t.type = "acid"

    if self.y > ground and  t.type != "acid" and (pygame.sprite.collide_rect(player,t) == False):
        print t.type
        self.y = ground
        self.isFalling = False
        self.isJumping = False
        #and Ground(acid=4).ground_tiles != "acid":

    else:
        pass

    self.rect.y = self.y

def draw(self, screen):
    if self.flip:
        img = pygame.transform.flip(self.image.getScaledImage(self.scale), True, False)
    else:
        img = self.image.getScaledImage(self.scale)
    #img_rect = img.get_rect()
    screen.blit(img, (self.x, self.y))

Tags: andrectimageselffalseimgifpygame