[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] my rpg game (so far)



On Tue, Nov 4, 2008 at 11:58 PM, Michael Fiano <michael.fiano@xxxxxxxxx> wrote:
> On Sat, 1 Nov 2008 05:06:08 -0400
> Michael Fiano <michael.fiano@xxxxxxxxx> wrote:
>
> I am stuck. I realized I need to blit the player the the map surface
> instead of the screen so that I can position the player at a given map
> position. The problem is if i change line 66 of player.py from:
>
> self.screen.blit(self.playerimgs[self.frame], (self.x,self.y))
>
> to:
>
> self.background.blit(self.playerimgs[self.frame], (self.x,self.y))
>
> The map (also on the background surface) does not get repainted
> properly. The player leaves trails when he moves. I'm not sure how to
> fix this, or why it even occurs. Somebody enlighten me?
>

No need to place him on the map itself, as long as you position the
player so that he is aligned with the background.  I assume you are
doing scrolling?  If you are scrolling by moving, the background, blit
the player this way:
self.screen.blit(self.playerimgs[self.frame],
(self.x+backgroundx,self.y+backgroundy))

Your way would work if you create a new copy each time:
this_frame_bg = self.background.copy()
this_frame_bg.blit(self.playerimgs[self.frame], (self.x,self.y))
But it is probably slower to copy a whole surface like this.