the console window, i have a script where i move a sprite in 4 directions and once
On Fri, Oct 31, 2008 at 4:15 PM, Luke Paireepinart
<rabidpoobear@xxxxxxxxx> wrote:
> Ok, I'm getting closer. I did this:
>
> if event.type == USEREVENT:
> keys = pygame.key.get_pressed()
> if keys[K_UP]:
> self.player.move = 1
> elif keys[K_DOWN]:
> self.player.move = 2
> elif keys[K_LEFT]:
> self.player.move = 3
> elif keys[K_RIGHT]:
> self.player.move = 4
>
> Here's how it works:
> player.move = 0-4 where 0 = stop, 1 = up, 2 = down, 3 = left, 4 = right
You need separate values for x and y. and don't use elifs, use a set
of ifs. The way you're doing it disallows for diagonal movement and
creates some other issues.