I cant move up and down with my code
<p>Here is the code I used to use a rectangle move for a game. But every time I press the up and down keys, it goes left and right. If you can paste the correct version in your answer. Thanks!!!!    </p>

<p>p.s the # is a comment</p>

<pre><code>#to start pygame
import pygame

pygame.init()

#game window
gameWindow = pygame.display.set_mode((1000, 600))
pygame.display.set_caption("SimpleShooter")

#moving character
class PlayerActive():
    def __init__(self):

        self.image = pygame.Surface((50, 50))
        self.image.fill((0, 0, 255))
        self.rect = self.image.get_rect()

        self.rect.x = 50
        self.rect.y = 50

        self.speed = 1

    def move(self, xdir, ydir):
        self.rect.x += xdir*self.speed
        self.rect.x += ydir*self.speed

player = PlayerActive()

#starting and ending the game
gameActive = True
while gameActive:
    for event in pygame.event.get():
        #print event (optional)
        if event.type == pygame.QUIT:
            gameActive = False

    #moving character
    activekey = pygame.key.get_pressed()

    if activekey[pygame.K_RIGHT]:
        player.move(1, 0)
    if activekey[pygame.K_LEFT]:
        player.move(-1, 0)
    if activekey[pygame.K_UP]:
        player.move(0, -1)
    if activekey[pygame.K_DOWN]:
        player.move(0, 1)

    #change the main screen
    gameWindow.fill((255, 255, 255))
    #place moving character
    gameWindow.blit(player.image, player.rect)
    #how to draw rectangles
    pygame.draw.rect(gameWindow, (0, 0, 0), (50, 195, 50, 50), 5)
    #use to show shapes on gameWindow
    pygame.display.update()

#quit game
pygame.quit()
quit()
</code></pre>

<p>The following: </p>

<pre><code>def move(self, xdir, ydir):
    self.rect.x += xdir*self.speed
    self.rect.x += ydir*self.speed
</code></pre>

<p>Should be changed to:</p>

<pre><code>def move(self, xdir, ydir):
    self.rect.x += xdir*self.speed
    self.rect.y += ydir*self.speed
</code></pre>

<p>You were always incrementing <code>x</code> regardless of if the change was in <code>xdir</code> or <code>ydir</code>. The change change <code>rect.y</code> for <code>ydir</code> and <code>rect.x</code> for <code>xdir</code>.</p>

python pygame