for now removed card class from hirarchy and added possibillity to render sprites on screen
This commit is contained in:
@ -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:
|
||||
|
@ -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
|
@ -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
|
@ -1,17 +0,0 @@
|
||||
|
||||
|
||||
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
|
@ -1,17 +0,0 @@
|
||||
|
||||
|
||||
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
|
@ -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
|
||||
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)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user