added old code, fixed it (mostly), merged some new code to the old code, made it mostly runnable
This commit is contained in:
85
New_Client/Classes/Engine/Components/BoardField.py
Normal file
85
New_Client/Classes/Engine/Components/BoardField.py
Normal file
@ -0,0 +1,85 @@
|
||||
import os
|
||||
import pygame
|
||||
|
||||
class BoardField(pygame.sprite.Sprite):
|
||||
__fieldID:str
|
||||
__name:str
|
||||
__side:str
|
||||
__type:str
|
||||
__pos:pygame.Vector2
|
||||
__size:tuple
|
||||
__color:tuple = (255,255,255)
|
||||
__holdsCard = None
|
||||
image:pygame.image
|
||||
rect:pygame.rect
|
||||
|
||||
def __init__(self, name:str, side:str, type:str, pos:pygame.Vector2, imagePath:str, fid:str):
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
self.__name = name
|
||||
self.__side = side
|
||||
self.__type = type
|
||||
self.__pos = pos
|
||||
self.__holdsCard = None
|
||||
self.__fieldID = fid
|
||||
|
||||
# Überprüfen des Dateipfads
|
||||
if not os.path.exists(imagePath):
|
||||
print("could not find image Location.")
|
||||
else:
|
||||
# Wenn der Pfad gültig ist, versuchen Sie, das Bild zu laden
|
||||
self.image = pygame.image.load(imagePath).convert_alpha()
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.center = self.__pos
|
||||
|
||||
def getName(self) -> str:
|
||||
return self.__name
|
||||
|
||||
def getSide(self) -> str:
|
||||
return self.__side
|
||||
|
||||
def getType(self) -> str:
|
||||
return self.__type
|
||||
|
||||
def getPos(self) -> pygame.Vector2:
|
||||
return self.__pos
|
||||
|
||||
def getSize(self) -> tuple:
|
||||
return self.__size
|
||||
|
||||
def getColor(self) -> tuple:
|
||||
return self.__color
|
||||
|
||||
def getRect(self) -> pygame.Rect:
|
||||
return self.rect
|
||||
|
||||
def getImage(self) -> pygame.image:
|
||||
return self.image
|
||||
|
||||
def getHoldingCard(self):
|
||||
return self.__holdsCard
|
||||
|
||||
def setName(self, name:str) -> str:
|
||||
self.__name = name
|
||||
return self.__name
|
||||
|
||||
def setType(self,type:str) -> str:
|
||||
self.__type = type
|
||||
return self.__type
|
||||
|
||||
def setPos(self, pos:pygame.Vector2) -> pygame.Vector2:
|
||||
self.pos = pos
|
||||
return self.__pos
|
||||
|
||||
def setSize(self, size:tuple) -> tuple:
|
||||
self.__size = size
|
||||
return self.__size
|
||||
|
||||
def setColor(self, color:tuple) -> tuple:
|
||||
self.__color = color
|
||||
return self.__color
|
||||
|
||||
def setCardHolding(self, card):
|
||||
self.__holdsCard = card
|
||||
|
||||
def getFieldID(self) -> str:
|
||||
return self.__fieldID
|
46
New_Client/Classes/Engine/Components/Label.py
Normal file
46
New_Client/Classes/Engine/Components/Label.py
Normal file
@ -0,0 +1,46 @@
|
||||
import pygame
|
||||
|
||||
class Label:
|
||||
rect:pygame.rect
|
||||
image:pygame.image
|
||||
__screen:pygame.surface
|
||||
__text:str
|
||||
__pos:pygame.Vector2
|
||||
__font:pygame.font
|
||||
font:pygame.font
|
||||
__name:str
|
||||
|
||||
def __init__(self, name:str, screen:pygame.surface, text:str, pos:pygame.Vector2, size:float=20, color:str="white"):
|
||||
self.__font = pygame.font.SysFont("Arial", size)
|
||||
self.font = pygame.font.SysFont("Arial", size)
|
||||
self.image = self.font.render(text, 1, color)
|
||||
_, _, w, h = self.image.get_rect()
|
||||
self.__pos = pos
|
||||
self.rect = pygame.Rect(self.__pos.x, self.__pos.y, w, h)
|
||||
self.__screen = screen
|
||||
self.__text = text
|
||||
|
||||
def getText(self) -> str:
|
||||
return self.__text
|
||||
|
||||
def getFont(self) -> pygame.font:
|
||||
return self.__font
|
||||
|
||||
def getPos(self) -> pygame.Vector2:
|
||||
return self.__pos
|
||||
|
||||
def getName(self) -> str:
|
||||
return self.__name
|
||||
|
||||
def setText(self, newtext:str, color:str="white"):
|
||||
self.image = self.font.render(newtext, 1, color)
|
||||
|
||||
def setFont(self, font:pygame.font, size:float, color:str="white"):
|
||||
self.__font = pygame.font.SysFont(font, size)
|
||||
self.change_text(self.text, color)
|
||||
|
||||
def setPos(self, pos:pygame.Vector2):
|
||||
self.__pos = pos
|
||||
|
||||
def draw(self):
|
||||
self.__screen.blit(self.image, (self.rect))
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user