Python Forum
[PyGame] Rect object penetrates wall on one side
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Rect object penetrates wall on one side
#2
I just commented out these lines of code which seem to be redundant and now it works as I might expect it to. Let me know if you agree.
Edit:
Nope, sorry. Now it penetrates from the other direction Blush
		for block in block_hit_list:
			if self.change_x > 0:
				self.rect.left = block.rect.right
			else:
				self.rect.right = block.rect.left
			'''
			if self.change_x < 0:
				self.rect.right = block.rect.left
			else:
				self.rect.left = block.rect.right
			''' 
Reply


Messages In This Thread
Rect object penetrates wall on one side - by Jan_97 - Dec-30-2021, 08:52 PM
RE: Rect object penetrates wall on one side - by BashBedlam - Dec-30-2021, 10:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Make a wall in turtle module Jan_97 2 7,385 Aug-18-2021, 08:47 PM
Last Post: Jan_97
  [PyGame] printing integers on pygame.draw.rect Shyckh 1 2,581 Aug-22-2020, 11:44 AM
Last Post: metulburr
  rect object not loading BlueClaw 2 4,222 Dec-11-2019, 04:25 PM
Last Post: BlueClaw
  Multiple wall collision in pacman rustyjoe 4 4,251 Aug-11-2019, 08:08 AM
Last Post: rustyjoe
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 3,779 Jun-11-2019, 08:32 PM
Last Post: metulburr
  [PyGame] assigning rect to sprite pfaber11 1 2,250 May-18-2019, 05:39 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