Pygame grenzt an Fenster
#for setting boundaries you can use the and command instead of making another if statement so for left
#get your x value and make it less than your velocity like
x > vel
#for right have x be less than your set bourders and subtract it by your width and velocity like
x < 500 - 25 - vel
#it's almost the same for moving up and down but with the y value instead of the x
Spaget