added card types
This commit is contained in:
6
Game_Client/.vscode/settings.json
vendored
Normal file
6
Game_Client/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"pygame",
|
||||
"yvel"
|
||||
]
|
||||
}
|
53
Game_Client/Classes/System/App.py
Normal file
53
Game_Client/Classes/System/App.py
Normal file
@ -0,0 +1,53 @@
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
from Classes.System.Window import Window
|
||||
from Classes.System.InputHandler import InputHandler
|
||||
|
||||
|
||||
class App:
|
||||
|
||||
__window:Window
|
||||
__running:bool = True
|
||||
__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"):
|
||||
self.__window = Window(width=width, height=height, title=title)
|
||||
self.startGameLoop()
|
||||
self.onCleanup()
|
||||
|
||||
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)
|
||||
|
||||
self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed))
|
||||
|
||||
# event handler
|
||||
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()
|
24
Game_Client/Classes/System/InputHandler.py
Normal file
24
Game_Client/Classes/System/InputHandler.py
Normal 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))
|
||||
|
22
Game_Client/Classes/System/Objects/Cards/Card.py
Normal file
22
Game_Client/Classes/System/Objects/Cards/Card.py
Normal 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
|
14
Game_Client/Classes/System/Objects/Cards/MonsterCard.py
Normal file
14
Game_Client/Classes/System/Objects/Cards/MonsterCard.py
Normal 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
|
17
Game_Client/Classes/System/Objects/Cards/SpellCard.py
Normal file
17
Game_Client/Classes/System/Objects/Cards/SpellCard.py
Normal 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
|
17
Game_Client/Classes/System/Objects/Cards/TrapCard.py
Normal file
17
Game_Client/Classes/System/Objects/Cards/TrapCard.py
Normal 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
|
37
Game_Client/Classes/System/Window.py
Normal file
37
Game_Client/Classes/System/Window.py
Normal file
@ -0,0 +1,37 @@
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
class Window:
|
||||
__width:int = 800
|
||||
__height:int = 600 # takes 80% of width which tranlates to 640
|
||||
__title:str = "python game engine"
|
||||
__screen:pygame.Surface
|
||||
__clock:pygame.time.Clock
|
||||
|
||||
def __init__(self, width:int=800, height:int=600, title:str="python game engine"):
|
||||
self.__width = width
|
||||
self.__height = height
|
||||
self.__title = title
|
||||
|
||||
self.__screen = pygame.display.set_mode((self.__width, self.__height))
|
||||
pygame.display.init()
|
||||
|
||||
pygame.display.set_caption = self.__title
|
||||
|
||||
# set framerate
|
||||
|
||||
|
||||
def Render(self):
|
||||
pass
|
||||
|
||||
def setWidth(self, width:int):
|
||||
self.__width = width
|
||||
|
||||
def setHeight(self, height:int):
|
||||
self.__height = height
|
||||
|
||||
def setTitle(self, title:str):
|
||||
self.__title = title
|
||||
|
||||
def getScreen(self) -> pygame.surface:
|
||||
return self.__screen
|
BIN
Game_Client/Classes/System/__pycache__/App.cpython-311.pyc
Normal file
BIN
Game_Client/Classes/System/__pycache__/App.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Game_Client/Classes/System/__pycache__/App.cpython-312.pyc
Normal file
BIN
Game_Client/Classes/System/__pycache__/App.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc
Normal file
BIN
Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Game_Client/Classes/System/__pycache__/Window.cpython-312.pyc
Normal file
BIN
Game_Client/Classes/System/__pycache__/Window.cpython-312.pyc
Normal file
Binary file not shown.
7
Game_Client/main.py
Normal file
7
Game_Client/main.py
Normal file
@ -0,0 +1,7 @@
|
||||
import pygame
|
||||
from Classes.System.App import App
|
||||
|
||||
if __name__ == "__main__":
|
||||
pygame.init()
|
||||
game = App()
|
||||
game.onExecute()
|
Reference in New Issue
Block a user