0

I'm making a platformer game in pygame and I'm stuck at a part where the player is supposed to fall when standing on an acid tile but I keep having errors. Here's the code to check that:

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))
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 3
    posting the errors would be helpful. – Josh Adams Jul 31 '17 at 19:15
  • Please provide a [minimal but complete example](https://stackoverflow.com/help/mcve) that we can copy and run, otherwise it's difficult to help you. Also, describe the desired behavior and the errors in detail. – skrx Jul 31 '17 at 19:36

0 Answers0