diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a8b7a75 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python:app", + "type": "python", + "request": "launch", + "program": "Game Client/main.py", + "console": "integratedTerminal", + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/Game Client/Classes/System/InputHandler.py b/Game Client/Classes/System/InputHandler.py deleted file mode 100644 index 61c51b8..0000000 --- a/Game Client/Classes/System/InputHandler.py +++ /dev/null @@ -1,23 +0,0 @@ -import pygame - -class InputHandler: - # returns pressed key - def getPressed(): - return pygame.key.get_pressed() - - def getInputAxis() -> tuple: - xvel:int = 0 - yvel:int = 0 - - # construct x and y velocity input axis - if InputHandler.getPressed()[pygame.K_a]: - xvel = -1 - if InputHandler.getPressed()[pygame.K_d]: - xvel = 1 - if InputHandler.getPressed()[pygame.K_w]: - yvel = -1 - if InputHandler.getPressed()[pygame.K_s]: - yvel = 1 - - return tuple((xvel, yvel)) - \ No newline at end of file diff --git a/Game Client/Classes/__pycache__/App.cpython-311.pyc b/Game Client/Classes/__pycache__/App.cpython-311.pyc deleted file mode 100644 index 90821aa..0000000 Binary files a/Game Client/Classes/__pycache__/App.cpython-311.pyc and /dev/null differ diff --git a/Game Client/Classes/__pycache__/Window.cpython-311.pyc b/Game Client/Classes/__pycache__/Window.cpython-311.pyc deleted file mode 100644 index c689e06..0000000 Binary files a/Game Client/Classes/__pycache__/Window.cpython-311.pyc and /dev/null differ diff --git a/Game Client/.vscode/settings.json b/Game_Client/.vscode/settings.json similarity index 100% rename from Game Client/.vscode/settings.json rename to Game_Client/.vscode/settings.json diff --git a/Game Client/Classes/System/App.py b/Game_Client/Classes/System/App.py similarity index 77% rename from Game Client/Classes/System/App.py rename to Game_Client/Classes/System/App.py index a937ec8..ff6efe6 100644 --- a/Game Client/Classes/System/App.py +++ b/Game_Client/Classes/System/App.py @@ -31,16 +31,23 @@ class App: self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed)) # event handler - for event in pygame.event.get(): - if event.type == pygame.QUIT: - self.onCleanup() + self.handleEvent(pygame.event.get()) + # emits update to the game pygame.display.update() + # handles incoming eventqueue + def handleEvent(self, events): + for event in events: + if event.type == pygame.QUIT: + self.onCleanup() + + # sets the running state for the gameloop def setRunning(self, running:bool): self.__running = running + # ensures the gameloop stops running and the pygame instance is stopped properly def onCleanup(self): self.__running = False pygame.quit() \ No newline at end of file diff --git a/Game_Client/Classes/System/InputHandler.py b/Game_Client/Classes/System/InputHandler.py new file mode 100644 index 0000000..addfcfa --- /dev/null +++ b/Game_Client/Classes/System/InputHandler.py @@ -0,0 +1,24 @@ +import pygame + +class InputHandler: + # returns pressed key + def getPressed(): + return pygame.key.get_pressed() + + # takes in movement inputs and maps them to x and y axis + def getInputAxis() -> tuple: + xvel:int = 0 + yvel:int = 0 + + # construct x and y velocity input axis + if InputHandler.getPressed()[pygame.K_a] or InputHandler.getPressed()[pygame.K_LEFT]: + xvel = -1 + if InputHandler.getPressed()[pygame.K_d] or InputHandler.getPressed()[pygame.K_RIGHT]: + xvel = 1 + if InputHandler.getPressed()[pygame.K_w] or InputHandler.getPressed()[pygame.K_UP]: + yvel = -1 + if InputHandler.getPressed()[pygame.K_s] or InputHandler.getPressed()[pygame.K_DOWN]: + yvel = 1 + + return tuple((xvel, yvel)) + \ No newline at end of file diff --git a/Game_Client/Classes/System/Objects/Cards/Card.py b/Game_Client/Classes/System/Objects/Cards/Card.py new file mode 100644 index 0000000..b25416e --- /dev/null +++ b/Game_Client/Classes/System/Objects/Cards/Card.py @@ -0,0 +1,22 @@ +import pygame + + +class Card: + __name:str + __artwork:pygame.image + + def __init__(self, name:str, imagePath:str): + + if name == "": + return ValueError.add_note("Card: name cannot be empty") + if imagePath == "": + return ValueError.add_note("Card: imagePath cannot be empty") + + self.__name = name + self.__image = pygame.image.load(imagePath) + + def getName(self) -> str: + return self.__name + + def getArtwork(self) -> pygame.image: + return self.__image \ No newline at end of file diff --git a/Game_Client/Classes/System/Objects/Cards/MonsterCard.py b/Game_Client/Classes/System/Objects/Cards/MonsterCard.py new file mode 100644 index 0000000..c0d98e1 --- /dev/null +++ b/Game_Client/Classes/System/Objects/Cards/MonsterCard.py @@ -0,0 +1,14 @@ +import json +from Game_Client.Classes.System.Objects.Cards.Card import Card + +class MonsterCard(Card): + __attacks:[] + + def __init__(self, asset:str): + data = json.load(open(asset)) + + for attack in range(data["attacks"]): + self.__attacks.add(attack) + + def attacks(self): + return self.__attacks \ No newline at end of file diff --git a/Game_Client/Classes/System/Objects/Cards/SpellCard.py b/Game_Client/Classes/System/Objects/Cards/SpellCard.py new file mode 100644 index 0000000..6f918e1 --- /dev/null +++ b/Game_Client/Classes/System/Objects/Cards/SpellCard.py @@ -0,0 +1,17 @@ + + +import json +from Game_Client.Classes.System.Objects.Cards.Card import Card + + +class SpellCard(Card): + __description:str + + def __init__(self, asset:str): + data = json.load(open(asset)) + + super.__init__(data["name"], data["image"]) + self.__description = data["description"] + + def getDescription(self): + return self.__description \ No newline at end of file diff --git a/Game_Client/Classes/System/Objects/Cards/TrapCard.py b/Game_Client/Classes/System/Objects/Cards/TrapCard.py new file mode 100644 index 0000000..9a30a36 --- /dev/null +++ b/Game_Client/Classes/System/Objects/Cards/TrapCard.py @@ -0,0 +1,17 @@ + + +from Game_Client.Classes.System.Objects.Cards.Card import Card +import json + +class SpellCard(Card): + __description:str + + def __init__(self, asset:str): + + data = json.load(open(asset)) + + super.__init__(data["name"], data["image"]) + self.__description = data["description"] + + def getDescription(self): + return self.__description \ No newline at end of file diff --git a/Game Client/Classes/System/Window.py b/Game_Client/Classes/System/Window.py similarity index 100% rename from Game Client/Classes/System/Window.py rename to Game_Client/Classes/System/Window.py diff --git a/Game Client/Classes/System/__pycache__/App.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc similarity index 100% rename from Game Client/Classes/System/__pycache__/App.cpython-311.pyc rename to Game_Client/Classes/System/__pycache__/App.cpython-311.pyc diff --git a/Game_Client/Classes/System/__pycache__/App.cpython-312.pyc b/Game_Client/Classes/System/__pycache__/App.cpython-312.pyc new file mode 100644 index 0000000..351f2dd Binary files /dev/null and b/Game_Client/Classes/System/__pycache__/App.cpython-312.pyc differ diff --git a/Game Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc similarity index 100% rename from Game Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc rename to Game_Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc diff --git a/Game_Client/Classes/System/__pycache__/InputHandler.cpython-312.pyc b/Game_Client/Classes/System/__pycache__/InputHandler.cpython-312.pyc new file mode 100644 index 0000000..a2216a9 Binary files /dev/null and b/Game_Client/Classes/System/__pycache__/InputHandler.cpython-312.pyc differ diff --git a/Game Client/Classes/System/__pycache__/Window.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc similarity index 100% rename from Game Client/Classes/System/__pycache__/Window.cpython-311.pyc rename to Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc diff --git a/Game_Client/Classes/System/__pycache__/Window.cpython-312.pyc b/Game_Client/Classes/System/__pycache__/Window.cpython-312.pyc new file mode 100644 index 0000000..f9aa200 Binary files /dev/null and b/Game_Client/Classes/System/__pycache__/Window.cpython-312.pyc differ diff --git a/Game Client/main.py b/Game_Client/main.py similarity index 100% rename from Game Client/main.py rename to Game_Client/main.py