Python Forum
Problem with collision detection...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with collision detection...
#4
For debugging print the values you are comparing and look at the values that are printed when player hits a wall.

    def collide_with_walls(self, dx=0, dy=0):
        for wall in walls:
            print(wall.rect.x, self.rect.x+dx, wall.rect.y, self.rect.y+dy)
            if wall.rect.x==self.rect.x + dx and wall.rect.y == self.rect.y + dy:
                return True
        return False
Reply


Messages In This Thread
RE: Problem with collision detection... - by ThomasL - Nov-12-2019, 07:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [PyGame] Problem with collision of player and enemy Nekotrooper 1 971 Dec-08-2023, 03:29 PM
Last Post: deanhystad
  can't get collision detection to work in platform game chairmanme0wme0w 10 4,316 Aug-19-2022, 03:51 PM
Last Post: deanhystad
  [PyGame] Collision in not happening onizuka 3 3,587 Sep-07-2020, 11:30 AM
Last Post: metulburr
  [PyGame] No collision detection onizuka 6 3,895 Aug-18-2020, 01:29 PM
Last Post: onizuka
  Arcade Collision Problem randor 0 2,780 Oct-28-2019, 11:17 PM
Last Post: randor
  Multiple wall collision in pacman rustyjoe 4 4,322 Aug-11-2019, 08:08 AM
Last Post: rustyjoe
  drawing, moving, and collision problems (pygame) SheeppOSU 26 15,511 Apr-22-2019, 03:09 AM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

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