Python Forum
player just randomly teleporting to the edge of a platform in pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
player just randomly teleporting to the edge of a platform in pygame
#2
Once you land on the floor you start doing this:
    def handle_collision(self, floor):
        self.y = floor.y - self.height
        self.y_velocity = 0
        self.jumping = False
        if (
            self.x < floor.x + floor.width and self.x > floor.x
        ):  # Check if collision is occurring on the left edge
            if self.x < screen.get_width() - self.width:
                self.x = floor.x + floor.width
            else:
                self.x = floor.x + floor.width
This forces you to go to floor.x + floor.width
Reply


Messages In This Thread
RE: player just randomly teleporting to the edge of a platform in pygame - by deanhystad - Jan-24-2023, 09:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Sprites just randomly appear and dissapear in my pygame.sprite.GoupeSingle trueShadoWrr 2 2,034 Feb-13-2023, 09:34 AM
Last Post: Vadanane
  [PyGame] Players not falling from the platform, and some other errors. urmom33 1 1,664 Jan-23-2023, 10:28 PM
Last Post: deanhystad
  [PyGame] pygame, help with making a function to detect collision between player and enemy. Kris1996 3 3,389 Mar-07-2020, 12:32 PM
Last Post: Kris1996
  Randomly selecting sprite from group? michael1789 5 4,192 Nov-14-2019, 10:43 PM
Last Post: michael1789
  [PyGame] Rectangle keeps teleporting? keyfive 1 3,241 Jun-27-2018, 11:49 PM
Last Post: sonnekrieger7
  [PyGame] move randomly sprites reutB 4 8,287 Mar-29-2017, 01:12 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020