added fixed fps of 60 and changed input axis system to support multiple inputs
This commit is contained in:
parent
5d17e5a487
commit
0b5aef794a
@ -11,7 +11,8 @@ class App:
|
||||
__running:bool = True
|
||||
__player = pygame.Rect((300,250, 50,50))
|
||||
__FPS = 60
|
||||
__speed = 1
|
||||
__speed = 5
|
||||
__clock = pygame.time.Clock()
|
||||
|
||||
def __init__(self, width:int=800, height:int=600, title:str="default title"):
|
||||
self.__window = Window(width=width, height=height, title=title)
|
||||
@ -20,6 +21,9 @@ class App:
|
||||
|
||||
def startGameLoop(self):
|
||||
while self.__running:
|
||||
|
||||
self.__clock.tick(self.__FPS)
|
||||
|
||||
#temporary refresh
|
||||
self.__window.getScreen().fill((0,0,0))
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,0,0), self.__player)
|
||||
|
@ -12,11 +12,11 @@ class InputHandler:
|
||||
# construct x and y velocity input axis
|
||||
if InputHandler.getPressed()[pygame.K_a]:
|
||||
xvel = -1
|
||||
elif InputHandler.getPressed()[pygame.K_d]:
|
||||
if InputHandler.getPressed()[pygame.K_d]:
|
||||
xvel = 1
|
||||
elif InputHandler.getPressed()[pygame.K_w]:
|
||||
if InputHandler.getPressed()[pygame.K_w]:
|
||||
yvel = -1
|
||||
elif InputHandler.getPressed()[pygame.K_s]:
|
||||
if InputHandler.getPressed()[pygame.K_s]:
|
||||
yvel = 1
|
||||
|
||||
return tuple((xvel, yvel))
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user