0

I'm new to game development. Trying to move an object in pygame. The same code seems to work fine with my friend on a windows and I am using a Mac. Moving the object seems to affect the background. Not sure what I'm doing wrong here. Any help is appreciated.

This is from the movement function in the object class

    if self.prevPos:
       self.parent_screen.blit(self.bk, self.prevPos)
    self.prevPos = (self.x, self.y)

    self.bk.blit(self.parent_screen, (0, 0), (*self.prevPos, SIZE, SIZE))
    self.parent_screen.blit(self.image, (self.x, self.y))
    pygame.display.update()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • You must explain why you are drawing something on the background. What are you trying to achieve? Can you elaborate? Please read [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – Rabbid76 Jan 15 '22 at 07:56
  • Yes, sorry about that. So I am drawing 2 backgrounds - 1 as the entire surface and 1 as a play area on top of the first one so that there is a play surface with a visible border. The code above is for the player object that is able to move with the arrow keys. Eventually the idea is to have an idea similar to snake where a goal object is spawned around the border which the player object should move towards.(1/2) – apat124 Jan 15 '22 at 18:06
  • Unfortunately we are getting stuck in having the player object change the background as it moves. What's even more strange is the exact same code behaves differently on my macbook versus my friend's computer running windows where there does not seem to be an issue (2/2) – apat124 Jan 15 '22 at 18:06

0 Answers0