diff --git a/Game_Client/Assets/Cards/MonsterCards/testmonstercard/card.png b/Game_Client/Assets/Cards/MonsterCards/testmonstercard/card.png new file mode 100644 index 0000000..320d60d Binary files /dev/null and b/Game_Client/Assets/Cards/MonsterCards/testmonstercard/card.png differ diff --git a/Game_Client/Assets/Cards/testmonstercard/testmonstercard.json b/Game_Client/Assets/Cards/MonsterCards/testmonstercard/testmonstercard.json similarity index 51% rename from Game_Client/Assets/Cards/testmonstercard/testmonstercard.json rename to Game_Client/Assets/Cards/MonsterCards/testmonstercard/testmonstercard.json index f8e3476..004566b 100644 --- a/Game_Client/Assets/Cards/testmonstercard/testmonstercard.json +++ b/Game_Client/Assets/Cards/MonsterCards/testmonstercard/testmonstercard.json @@ -1,14 +1,17 @@ { - "name": "testmonster", - "image":"Assets/Cards/testmonstercard/artwork.png", + "name": "Test Monster", + "image": "Assets/Cards/testmonstercard/cards.png", + "description": "can attack other monsters", "costs": 30, - "defence": 40, + "defense": 40, "attacks":[ { + "id":1, "name":"test attack", "damage":80 }, { + "id":2, "name":"test attack", "damage":80 } diff --git a/Game_Client/Assets/Cards/testmonstercard/artworkjson.png b/Game_Client/Assets/Cards/SpeelCards/testspellcard/artworkjson.png similarity index 100% rename from Game_Client/Assets/Cards/testmonstercard/artworkjson.png rename to Game_Client/Assets/Cards/SpeelCards/testspellcard/artworkjson.png diff --git a/Game_Client/Assets/Cards/testspellcard/testspellcard.json b/Game_Client/Assets/Cards/SpeelCards/testspellcard/testspellcard.json similarity index 100% rename from Game_Client/Assets/Cards/testspellcard/testspellcard.json rename to Game_Client/Assets/Cards/SpeelCards/testspellcard/testspellcard.json diff --git a/Game_Client/Assets/Cards/testspellcard/artworkjson.png b/Game_Client/Assets/Cards/TrapCards/testtrapcard/artworkjson.png similarity index 100% rename from Game_Client/Assets/Cards/testspellcard/artworkjson.png rename to Game_Client/Assets/Cards/TrapCards/testtrapcard/artworkjson.png diff --git a/Game_Client/Assets/Cards/testtrapcard/testtrapcard.json b/Game_Client/Assets/Cards/TrapCards/testtrapcard/testtrapcard.json similarity index 100% rename from Game_Client/Assets/Cards/testtrapcard/testtrapcard.json rename to Game_Client/Assets/Cards/TrapCards/testtrapcard/testtrapcard.json diff --git a/Game_Client/Assets/Cards/testtrapcard/artworkjson.png b/Game_Client/Assets/Cards/testtrapcard/artworkjson.png deleted file mode 100644 index 9955a0c..0000000 Binary files a/Game_Client/Assets/Cards/testtrapcard/artworkjson.png and /dev/null differ diff --git a/Game_Client/Classes/Objects/Cards/Card.py b/Game_Client/Classes/Objects/Cards/Card.py new file mode 100644 index 0000000..7deb9f1 --- /dev/null +++ b/Game_Client/Classes/Objects/Cards/Card.py @@ -0,0 +1,14 @@ +import json +import pygame + + +class Card(pygame.sprite.Sprite): + + + def __init__(self, pos:tuple, assetDir:str): + + if assetDir == "": + return ValueError.add_note("Card: imagePath cannot be empty") + + + diff --git a/Game_Client/Classes/Objects/Cards/MonsterCard.py b/Game_Client/Classes/Objects/Cards/MonsterCard.py new file mode 100644 index 0000000..e6b6054 --- /dev/null +++ b/Game_Client/Classes/Objects/Cards/MonsterCard.py @@ -0,0 +1,43 @@ +import json +from typing import Any + +import pygame + +class MonsterCard(pygame.sprite.Sprite): + __attacks = [] + __name:str + __description:str + image:pygame.image + rect:pygame.rect + + def __init__(self, pos:tuple, assetDir:str): + if assetDir == "": + return ValueError.add_note("Card: imagePath cannot be empty") + + pygame.sprite.Sprite.__init__(self) + + data = json.load(open(assetDir + "/testmonstercard.json")) + + self.__name = data["name"] + self.image = pygame.image.load(assetDir + "/card.png").convert_alpha() + self.rect = self.image.get_rect() + self.rect.center = pos + self.__description = data["description"] + + for attack in data["attacks"]: + self.__attacks.append(attack) + + def update(self): + pass + + def attacks(self): + return self.__attacks + + def getName(self) -> str: + return self.__name + + def getCardSprite(self) -> pygame.image: + return self.__cardSprite + + def getDescription(self): + return self.__description diff --git a/Game_Client/Classes/System/Objects/Cards/SpellCard.py b/Game_Client/Classes/Objects/Cards/SpellCard.py similarity index 66% rename from Game_Client/Classes/System/Objects/Cards/SpellCard.py rename to Game_Client/Classes/Objects/Cards/SpellCard.py index 6f918e1..7a5fd12 100644 --- a/Game_Client/Classes/System/Objects/Cards/SpellCard.py +++ b/Game_Client/Classes/Objects/Cards/SpellCard.py @@ -1,7 +1,5 @@ - - import json -from Game_Client.Classes.System.Objects.Cards.Card import Card +from Classes.Objects.Cards.Card import Card class SpellCard(Card): @@ -10,8 +8,11 @@ class SpellCard(Card): def __init__(self, asset:str): data = json.load(open(asset)) - super.__init__(data["name"], data["image"]) + Card.__init__(data["name"], data["image"]) self.__description = data["description"] + def update(self): + pass + 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/Objects/Cards/TrapCard.py similarity index 66% rename from Game_Client/Classes/System/Objects/Cards/TrapCard.py rename to Game_Client/Classes/Objects/Cards/TrapCard.py index 9a30a36..ddbca52 100644 --- a/Game_Client/Classes/System/Objects/Cards/TrapCard.py +++ b/Game_Client/Classes/Objects/Cards/TrapCard.py @@ -1,6 +1,6 @@ -from Game_Client.Classes.System.Objects.Cards.Card import Card +from Classes.Objects.Cards.Card import Card import json class SpellCard(Card): @@ -10,8 +10,11 @@ class SpellCard(Card): data = json.load(open(asset)) - super.__init__(data["name"], data["image"]) + Card.__init__(data["name"], data["image"]) self.__description = data["description"] + def update(self): + pass + def getDescription(self): return self.__description \ No newline at end of file diff --git a/Game_Client/Classes/Objects/Cards/__pycache__/Card.cpython-311.pyc b/Game_Client/Classes/Objects/Cards/__pycache__/Card.cpython-311.pyc new file mode 100644 index 0000000..96ec119 Binary files /dev/null and b/Game_Client/Classes/Objects/Cards/__pycache__/Card.cpython-311.pyc differ diff --git a/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc b/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc new file mode 100644 index 0000000..f1a4275 Binary files /dev/null and b/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc differ diff --git a/Game_Client/Classes/System/App.py b/Game_Client/Classes/System/App.py index ff6efe6..d0a0d14 100644 --- a/Game_Client/Classes/System/App.py +++ b/Game_Client/Classes/System/App.py @@ -1,6 +1,7 @@ import pygame from pygame.locals import * +from Classes.Objects.Cards.MonsterCard import MonsterCard from Classes.System.Window import Window from Classes.System.InputHandler import InputHandler @@ -9,35 +10,41 @@ class App: __window:Window __running:bool = True - __player = pygame.Rect((300,250, 50,50)) + # __player = pygame.Rect((300,250, 50,50)) __FPS = 60 __speed = 5 __clock = pygame.time.Clock() - def __init__(self, width:int=800, height:int=600, title:str="default title"): + def __init__(self, width:int=1280, height:int=720, title:str="default title"): self.__window = Window(width=width, height=height, title=title) self.startGameLoop() self.onCleanup() def startGameLoop(self): + + # create sprite groups + cards = pygame.sprite.Group() + + testMonsterCard = MonsterCard((500,500), "Assets/Cards/MonsterCards/testmonstercard/") + cards.add(testMonsterCard) + 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) - - self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed)) + # update sprite groups + cards.update() + + # draw groups + self.__window.drawSpriteGroup(cards) # event handler self.handleEvent(pygame.event.get()) - # emits update to the game pygame.display.update() - # handles incoming eventqueue + # handles incoming event queue def handleEvent(self, events): for event in events: if event.type == pygame.QUIT: diff --git a/Game_Client/Classes/System/Objects/Cards/Card.py b/Game_Client/Classes/System/Objects/Cards/Card.py deleted file mode 100644 index b25416e..0000000 --- a/Game_Client/Classes/System/Objects/Cards/Card.py +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index c0d98e1..0000000 --- a/Game_Client/Classes/System/Objects/Cards/MonsterCard.py +++ /dev/null @@ -1,14 +0,0 @@ -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/Window.py b/Game_Client/Classes/System/Window.py index 9cb1f25..3c3d295 100644 --- a/Game_Client/Classes/System/Window.py +++ b/Game_Client/Classes/System/Window.py @@ -20,7 +20,6 @@ class Window: # set framerate - def Render(self): pass @@ -34,4 +33,9 @@ class Window: self.__title = title def getScreen(self) -> pygame.surface: - return self.__screen \ No newline at end of file + return self.__screen + + # draws a passed sprite group to the screen + def drawSpriteGroup(self, group:pygame.sprite.Group): + self.__screen.fill("grey100") + group.draw(self.__screen) \ No newline at end of file diff --git a/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc index 773e635..f0eeecc 100644 Binary files a/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc and b/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc differ diff --git a/Game_Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc index 8191c59..d1c7b3b 100644 Binary files a/Game_Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc and b/Game_Client/Classes/System/__pycache__/InputHandler.cpython-311.pyc differ diff --git a/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc index 242fbcc..4cea9d4 100644 Binary files a/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc and b/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc differ