Python Forum
Creating barriers/boundaries help for Pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating barriers/boundaries help for Pygame
#2
Tell the program that if your characters edge passes the edge of the screen to reset it to be on the screen. If you are using your pygame rect it is like this:

character.image = pygame.transform.scale(player, (30,30))
character.rect = character.image.get_rect()

if character.rect.right is > width:
    character.rect.right = width
I encourage you to learn the pygame Sprite class. It will make things a lot easier (like collecting coins) going forward.

This video helped me:
https://www.youtube.com/watch?v=Eltz-XJMxuU
Reply


Messages In This Thread
RE: Creating barriers/boundaries help for Pygame - by michael1789 - Mar-19-2020, 06:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Creating Pong in Pygame Russ_CW 2 2,908 Oct-11-2020, 11:56 AM
Last Post: Russ_CW

Forum Jump:

User Panel Messages

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