My Pygame script makes my character on screen pause when my mouse is moved -


i wanted make simple game in pygame moved character(a square) wasd keys. have achieved movement not smooth , when move mouse character refuses move.

i assume loop

    event in pygame.event.get():         if event.type pygame.quit:             pygame.quit()             sys.exit() 

i know stuck in loop whilst there input i'm not sure how fix without not being able close program.

here main game loop:

while launchgame:     event in pygame.event.get():         if event.type pygame.quit:             pygame.quit()             sys.exit()     screen.fill(white)     player.draw()     player.move()     pygame.display.flip() 

and here move script if helps:

    def move(self):     if event.type == pygame.keydown:         if pygame.key.get_pressed()[k_w]:             self.y -= self.speed         if pygame.key.get_pressed()[k_s]:             self.y += self.speed         if pygame.key.get_pressed()[k_a]:             self.x -= self.speed         if pygame.key.get_pressed()[k_d]:             self.x += self.speed 

how can fix this.

its simple typo. in second line have if event.type pygame.quit:

and should if event.type == pygame.quit:

if didn't work, try:

while running:     event in pygame.event.get():         if event.type pygame.quit:             running = false;     screen.fill(white)     player.draw()     player.move()     pygame.display.flip() 

and run program command line see if it's problem pycharm


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -