for now removed card class from hirarchy and added possibillity to render sprites on screen
This commit is contained in:
parent
0d89b1ce84
commit
8d7a67a454
BIN
Game_Client/Assets/Cards/MonsterCards/testmonstercard/card.png
Normal file
BIN
Game_Client/Assets/Cards/MonsterCards/testmonstercard/card.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "testmonster",
|
"name": "Test Monster",
|
||||||
"image":"Assets/Cards/testmonstercard/artwork.png",
|
"image": "Assets/Cards/testmonstercard/cards.png",
|
||||||
|
"description": "can attack other monsters",
|
||||||
"costs": 30,
|
"costs": 30,
|
||||||
"defence": 40,
|
"defense": 40,
|
||||||
"attacks":[
|
"attacks":[
|
||||||
{
|
{
|
||||||
|
"id":1,
|
||||||
"name":"test attack",
|
"name":"test attack",
|
||||||
"damage":80
|
"damage":80
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id":2,
|
||||||
"name":"test attack",
|
"name":"test attack",
|
||||||
"damage":80
|
"damage":80
|
||||||
}
|
}
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB |
14
Game_Client/Classes/Objects/Cards/Card.py
Normal file
14
Game_Client/Classes/Objects/Cards/Card.py
Normal file
@ -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")
|
||||||
|
|
||||||
|
|
||||||
|
|
43
Game_Client/Classes/Objects/Cards/MonsterCard.py
Normal file
43
Game_Client/Classes/Objects/Cards/MonsterCard.py
Normal file
@ -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
|
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from Game_Client.Classes.System.Objects.Cards.Card import Card
|
from Classes.Objects.Cards.Card import Card
|
||||||
|
|
||||||
|
|
||||||
class SpellCard(Card):
|
class SpellCard(Card):
|
||||||
@ -10,8 +8,11 @@ class SpellCard(Card):
|
|||||||
def __init__(self, asset:str):
|
def __init__(self, asset:str):
|
||||||
data = json.load(open(asset))
|
data = json.load(open(asset))
|
||||||
|
|
||||||
super.__init__(data["name"], data["image"])
|
Card.__init__(data["name"], data["image"])
|
||||||
self.__description = data["description"]
|
self.__description = data["description"]
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return self.__description
|
return self.__description
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
from Game_Client.Classes.System.Objects.Cards.Card import Card
|
from Classes.Objects.Cards.Card import Card
|
||||||
import json
|
import json
|
||||||
|
|
||||||
class SpellCard(Card):
|
class SpellCard(Card):
|
||||||
@ -10,8 +10,11 @@ class SpellCard(Card):
|
|||||||
|
|
||||||
data = json.load(open(asset))
|
data = json.load(open(asset))
|
||||||
|
|
||||||
super.__init__(data["name"], data["image"])
|
Card.__init__(data["name"], data["image"])
|
||||||
self.__description = data["description"]
|
self.__description = data["description"]
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return self.__description
|
return self.__description
|
Binary file not shown.
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
|
|
||||||
|
from Classes.Objects.Cards.MonsterCard import MonsterCard
|
||||||
from Classes.System.Window import Window
|
from Classes.System.Window import Window
|
||||||
from Classes.System.InputHandler import InputHandler
|
from Classes.System.InputHandler import InputHandler
|
||||||
|
|
||||||
@ -9,31 +10,37 @@ class App:
|
|||||||
|
|
||||||
__window:Window
|
__window:Window
|
||||||
__running:bool = True
|
__running:bool = True
|
||||||
__player = pygame.Rect((300,250, 50,50))
|
# __player = pygame.Rect((300,250, 50,50))
|
||||||
__FPS = 60
|
__FPS = 60
|
||||||
__speed = 5
|
__speed = 5
|
||||||
__clock = pygame.time.Clock()
|
__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.__window = Window(width=width, height=height, title=title)
|
||||||
self.startGameLoop()
|
self.startGameLoop()
|
||||||
self.onCleanup()
|
self.onCleanup()
|
||||||
|
|
||||||
def startGameLoop(self):
|
def startGameLoop(self):
|
||||||
|
|
||||||
|
# create sprite groups
|
||||||
|
cards = pygame.sprite.Group()
|
||||||
|
|
||||||
|
testMonsterCard = MonsterCard((500,500), "Assets/Cards/MonsterCards/testmonstercard/")
|
||||||
|
cards.add(testMonsterCard)
|
||||||
|
|
||||||
while self.__running:
|
while self.__running:
|
||||||
|
|
||||||
self.__clock.tick(self.__FPS)
|
self.__clock.tick(self.__FPS)
|
||||||
|
|
||||||
#temporary refresh
|
# update sprite groups
|
||||||
self.__window.getScreen().fill((0,0,0))
|
cards.update()
|
||||||
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))
|
# draw groups
|
||||||
|
self.__window.drawSpriteGroup(cards)
|
||||||
|
|
||||||
# event handler
|
# event handler
|
||||||
self.handleEvent(pygame.event.get())
|
self.handleEvent(pygame.event.get())
|
||||||
|
|
||||||
|
|
||||||
# emits update to the game
|
# emits update to the game
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
|
@ -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
|
|
@ -20,7 +20,6 @@ class Window:
|
|||||||
|
|
||||||
# set framerate
|
# set framerate
|
||||||
|
|
||||||
|
|
||||||
def Render(self):
|
def Render(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -35,3 +34,8 @@ class Window:
|
|||||||
|
|
||||||
def getScreen(self) -> pygame.surface:
|
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.
Loading…
x
Reference in New Issue
Block a user