I am trying to move a rectangle in Pygame using coordinates but won't work

Posted by user1821449 on Stack Overflow See other posts from Stack Overflow or by user1821449
Published on 2012-11-13T16:58:03Z Indexed on 2012/11/13 16:59 UTC
Read the original article Hit count: 246

Filed under:
|
|

this is my code

    import pygame
    from pygame.locals import *
    import sys
    pygame.init()
    pygame.display.set_caption("*no current mission*")
    size = (1280, 750)
    screen = pygame.display.set_mode(size)
    clock = pygame.time.Clock()
    bg = pygame.image.load("bg1.png")
    guy = pygame.image.load("hero_stand.png")
    rect = guy.get_rect()
    x = 10
    y = 10
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                if event.type == KEYDOWN:
                    _if event.key == K_RIGHT:
                        x += 5
                        rect.move(x,y)_
        rect.move(x,y) 
        screen.blit(bg,(0,0))
        screen.blit(guy, rect)
        pygame.display.flip()

it is just a simple test to see if i can get a rectangle to move. Everything seems to work except the code I put in italic.

© Stack Overflow or respective owner

Related posts about python

Related posts about pygame