Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99246

How to fix "pygame module has no member K_RIGHT"?

$
0
0

I decided to make a simple snake game, and I've hit a simple problem already. My lines along the line of if keys[pygame.K_RIGHT], if keys[pygame.K_LEFT] etc give me a "pygame has no member "K_RIGHT/K_LEFT" error.

I tried py -m pip uninstall pygame, then reinstalled it, however the error persisted. Even when running the program, pressing left/right/up/down doesn't work, and I get the same error when doing import pygame then pygame.init().

if keys[pygame.K_RIGHT]:
    self.player.moveright

if keys[pygame.K_LEFT]:
    self.player.moveleft

if keys[pygame.K_UP]:
    self.player.moveup

if keys[pygame.K_DOWN]:
    self.player.movedown

if keys[pygame.K_ESCAPE]:
    self._running=False

The sprite doesn't move, and I get the "no member" errors. What is going wrong?


Viewing all articles
Browse latest Browse all 99246

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>