changed some things and did other things
This commit is contained in:
parent
f69f5d0e5f
commit
b70ced94f7
@ -1,18 +1,72 @@
|
||||
import json
|
||||
from Classes.Objects.Cards.Card import Card
|
||||
from typing import Any
|
||||
|
||||
import pygame
|
||||
|
||||
class SpellCard(Card):
|
||||
from Classes.System.Components.InputHandler import InputHandler
|
||||
|
||||
class SpellCard(pygame.sprite.Sprite):
|
||||
__name:str
|
||||
__description:str
|
||||
__pos:pygame.Vector2
|
||||
__dragging:bool = False
|
||||
__offset:pygame.Vector2 = pygame.Vector2(0,0)
|
||||
__inputHandler: InputHandler
|
||||
__type:str = "SpellCard"
|
||||
image:pygame.image
|
||||
rect:pygame.rect
|
||||
|
||||
def __init__(self, asset:str):
|
||||
data = json.load(open(asset))
|
||||
def __init__(self, pos:pygame.Vector2, assetDir:str, inputHandler:InputHandler):
|
||||
if assetDir == "":
|
||||
return ValueError.add_note("Card: imagePath cannot be empty")
|
||||
|
||||
Card.__init__(data["name"], data["image"])
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
|
||||
data = json.load(open(assetDir + "/card.json"))
|
||||
self.__pos = pos
|
||||
self.__name = data["name"]
|
||||
self.image = pygame.image.load(assetDir + "/card.png").convert_alpha()
|
||||
self.rect = self.image.get_rect()
|
||||
self.dragging = False
|
||||
self.offset = pygame.Vector2(0, 0) # Offset zwischen der Karte und der Mausposition
|
||||
self.__inputHandler = inputHandler
|
||||
self.rect.center = self.__pos
|
||||
self.__description = data["description"]
|
||||
self.original_size = self.image.get_size()
|
||||
self.original_position = self.rect.center
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
if self.getDragging():
|
||||
mouse_pos = self.__inputHandler.getMousePos()
|
||||
self.__pos = mouse_pos
|
||||
self.rect.center = self.__pos
|
||||
|
||||
def getName(self) -> str:
|
||||
return self.__name
|
||||
|
||||
def getCardSprite(self) -> pygame.image:
|
||||
return self.__cardSprite
|
||||
|
||||
def getDescription(self):
|
||||
return self.__description
|
||||
return self.__description
|
||||
|
||||
def getDragging(self):
|
||||
return self.__dragging
|
||||
|
||||
def getOffset(self):
|
||||
return self.__offset
|
||||
|
||||
def getPos(self):
|
||||
return self.__pos
|
||||
|
||||
def getType(self):
|
||||
return self.__type
|
||||
|
||||
def setDragging(self, dragging:bool):
|
||||
self.__dragging = dragging
|
||||
|
||||
def setOffset(self, offset:pygame.Vector2):
|
||||
self.__offset = offset
|
||||
|
||||
def setPos(self, pos:pygame.Vector2):
|
||||
self.__pos = pos
|
@ -1,20 +1,72 @@
|
||||
|
||||
|
||||
from Classes.Objects.Cards.Card import Card
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
class SpellCard(Card):
|
||||
import pygame
|
||||
|
||||
from Classes.System.Components.InputHandler import InputHandler
|
||||
|
||||
class TrapCard(pygame.sprite.Sprite):
|
||||
__name:str
|
||||
__description:str
|
||||
__pos:pygame.Vector2
|
||||
__dragging:bool = False
|
||||
__offset:pygame.Vector2 = pygame.Vector2(0,0)
|
||||
__inputHandler: InputHandler
|
||||
__type:str = "SpellCard"
|
||||
image:pygame.image
|
||||
rect:pygame.rect
|
||||
|
||||
def __init__(self, asset:str):
|
||||
def __init__(self, pos:pygame.Vector2, assetDir:str, inputHandler:InputHandler):
|
||||
if assetDir == "":
|
||||
return ValueError.add_note("Card: imagePath cannot be empty")
|
||||
|
||||
data = json.load(open(asset))
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
|
||||
Card.__init__(data["name"], data["image"])
|
||||
data = json.load(open(assetDir + "/card.json"))
|
||||
self.__pos = pos
|
||||
self.__name = data["name"]
|
||||
self.__inputHandler = inputHandler
|
||||
self.__description = data["description"]
|
||||
self.original_size = self.image.get_size()
|
||||
self.original_position = self.rect.center
|
||||
self.offset = pygame.Vector2(0, 0) # Offset zwischen der Karte und der Mausposition
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.center = self.__pos
|
||||
self.image = pygame.image.load(assetDir + "/card.png").convert_alpha()
|
||||
self.__dragging = False
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
if self.getDragging():
|
||||
mouse_pos = self.__inputHandler.getMousePos()
|
||||
self.__pos = mouse_pos
|
||||
self.rect.center = self.__pos
|
||||
|
||||
def getName(self) -> str:
|
||||
return self.__name
|
||||
|
||||
def getCardSprite(self) -> pygame.image:
|
||||
return self.__cardSprite
|
||||
|
||||
def getDescription(self):
|
||||
return self.__description
|
||||
return self.__description
|
||||
|
||||
def getDragging(self):
|
||||
return self.__dragging
|
||||
|
||||
def getOffset(self):
|
||||
return self.__offset
|
||||
|
||||
def getPos(self):
|
||||
return self.__pos
|
||||
|
||||
def getType(self):
|
||||
return self.__type
|
||||
|
||||
def setDragging(self, dragging:bool):
|
||||
self.__dragging = dragging
|
||||
|
||||
def setOffset(self, offset:pygame.Vector2):
|
||||
self.__offset = offset
|
||||
|
||||
def setPos(self, pos:pygame.Vector2):
|
||||
self.__pos = pos
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user