added card types

This commit is contained in:
steev 2023-12-06 12:21:51 +01:00
parent 0b5aef794a
commit 4fbd1c6663
19 changed files with 120 additions and 26 deletions

16
.vscode/launch.json vendored Normal file
View File

@ -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
}
]
}

View File

@ -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))

View File

@ -31,16 +31,23 @@ class App:
self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed)) self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed))
# event handler # event handler
for event in pygame.event.get(): self.handleEvent(pygame.event.get())
if event.type == pygame.QUIT:
self.onCleanup()
# emits update to the game # emits update to the game
pygame.display.update() 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): def setRunning(self, running:bool):
self.__running = running self.__running = running
# ensures the gameloop stops running and the pygame instance is stopped properly
def onCleanup(self): def onCleanup(self):
self.__running = False self.__running = False
pygame.quit() pygame.quit()

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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