From 0b5aef794a8bb795d9ebd3c6a40b5d12e8af667b Mon Sep 17 00:00:00 2001 From: steev Date: Tue, 5 Dec 2023 22:07:34 +0100 Subject: [PATCH] added fixed fps of 60 and changed input axis system to support multiple inputs --- Game Client/Classes/System/App.py | 6 +++++- Game Client/Classes/System/InputHandler.py | 6 +++--- .../System/__pycache__/App.cpython-311.pyc | Bin 2981 -> 3180 bytes .../__pycache__/InputHandler.cpython-311.pyc | Bin 1458 -> 1446 bytes 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Game Client/Classes/System/App.py b/Game Client/Classes/System/App.py index a2ad099..a937ec8 100644 --- a/Game Client/Classes/System/App.py +++ b/Game Client/Classes/System/App.py @@ -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) diff --git a/Game Client/Classes/System/InputHandler.py b/Game Client/Classes/System/InputHandler.py index 5fc910e..61c51b8 100644 --- a/Game Client/Classes/System/InputHandler.py +++ b/Game Client/Classes/System/InputHandler.py @@ -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)) diff --git a/Game Client/Classes/System/__pycache__/App.cpython-311.pyc b/Game Client/Classes/System/__pycache__/App.cpython-311.pyc index 6e906df0461c95881be979c18709fd0c87709a65..773e635a3d5206383351c2bdbc8f00c80318d0c4 100644 GIT binary patch delta 865 zcmZ`$O=uHA7@f)fG`rcKY<{+FN~|%ZlC-uZDtHh}ZSARGf5byTa>#BWNt=|-dMOb+ z1ia+X@*V2I!y>2$K>~UbuYv~!TM7-qgL;vILINH{FU}<0K(G$Xo7p$-y?M+&8T>vZ zKa*tPYXJZ4RMRH1AmzEAWYp_7zgyEXVH_zqEkvOx(j2oY&k#yBAKb z47hB8JQqS%sDhl}iCK%(Ci}!8SL}pc3B2P}yaEj_l{}`en9wbOEKOf#Zfh%($!?Ug zg(hp~2ntG4Xu9hs#85eh>DetWNOmW;a_<~3^`#(Ybc S$Fbf*|3aH`KTkR6MEwQ4Y_v%L delta 648 zcmZur&r4KM6u#&En)mCz`)1xaO*5D=W+mEGq98RGfk_KNDQGbu6L_D{R4Uik#!M0h zf^gArh-ec-G_{TT3;Hj@RlA^CD6|q6-D|#3^1%JhIp6v2`OdFm_XPbwsY_(cyjY60 zHhl~0?T<569&tDJxhJ0=(*=vumRS#Y&?0rlS!^w6JZu^DkY^>6#Rl8}_}qnO03lw` z=V2Y&dLBmcyOPj+-#MxBb$)yq;w-}7zO>4v#RE`HD;mCyVtXFUrYngM!9@(z+03lDw*C4mK zxI?IO=9?el%gp!QGGWmHwXOIgfUoUY7{(v=5DZ|!S%p4qI~UrejhW~U-bt?s)c6& diff --git a/Game Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc b/Game Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc index 61954093144a02740d2753f9148fd85eb80932f7..8191c5946d04b540c76f44bce92382ce83193cd4 100644 GIT binary patch delta 118 zcmdnQy^Nc8IWI340}ylce#5NE&B!TsLs+!K