Проблема с считыванием нажатий клавиш Pygame
уважаемые форумчани. Я с вопросом, написал простую заготовку, с обычным движением, поддержкой музыки и прорисовкой спрайтов. Обычное движение оказалось не так и обычным, проблема с вводом клавиш, они попросту не регистрируются, снизу приложен код:
import pygame,sys
size=height,width=[852,480]
pygame.init()
screen=pygame.display.set_mode(size)
pygame.mixer.music.load('music.mp3')
pygame.mixer.music.play()
bg=pygame.image.load('bg.jpg')
clock=pygame.time.Clock()
walkLeft=[pygame.image.load('L1.png'),pygame.image.load('L2.png'),pygame.image.load('L3.png'),pygame.image.load('L4.png'),pygame.image.load('L5.png'),pygame.image.load('L6.png'),pygame.image.load('L7.png'),pygame.image.load('L8.png'),pygame.image.load('L9.png'),]
walkRight=[pygame.image.load('R1.png'),pygame.image.load('R2.png'),pygame.image.load('R3.png'),pygame.image.load('R4.png'),pygame.image.load('R5.png'),pygame.image.load('R6.png'),pygame.image.load('R7.png'),pygame.image.load('R8.png'),pygame.image.load('R9.png'),]
image_file=pygame.image.load('standing.png')
image=pygame.image.load('L1.png')
class player(pygame.sprite.Sprite):
def __init__(self,xspeed,x,y,isJump,Jumpcount,lastmove,walkCount):
self.x=x
self.lastmove=lastmove
self.y=y
self.isJump=isJump
self.Jumpcount=Jumpcount
self.xspeed=xspeed
def jump(self):
if self.jumpCount >= - 10:
if self.jumpCount < 0 :
self.y+= (self.jumpCount**2)/2
else:
self.y-= (self.jumpCount**2) / 2
self.jumpCount-=1
else:
self.isJump= False
self.jumpCount= 10
def moveLeft(self):
if self.walkCount+1==36:
self.walkCount=0
else:
self.walkCount+=1
image=pygame.image.load(walkRight[self.walkCount//4])
if self.x-self.xspeed>0:
self.x+=-self.xspeed
self.lastmove='Left'
def moveRight(self):
if self.walkCount+1==36:
self.walkCount=0
else:
self.walkCount+=1
image=pygame.image.load(walkLeft[self.walkCount//4])
if self.x+self.xspeed<width:
self.x+=self.xspeed
self.lastmove='Right'
Player228=player(10,40,50,False,10,'Right',1)
while True:
clock.tick(36)
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
player.jump()
if keys[pygame.K_a]:
player.moveLeft()
if keys[pygame.K_d]:
player.moveRight()
screen.blit(bg,(0,0))
screen.blit(image_file,(Player228.x,Player228.y))
pygame.display.flip()
Большая просьба указать на ошибку, ибо и вправду не понимаю что не так, заранее благодарю!