moved position system over to use vector2

This commit is contained in:
2023-12-11 15:32:33 +01:00
parent 4acb99cc84
commit 8c544556ed
14 changed files with 273 additions and 60 deletions

View File

@ -0,0 +1,55 @@
import pygame
class BoardField():
__name:str
__type:str
__pos:pygame.Vector2
__size:tuple
__color:tuple = (255,255,255)
_rect:pygame.Rect
def __init__(self, name:str, type:str, pos:pygame.Vector2, size:tuple, color:tuple):
self.__name = name
self.__type = type
self.__pos = pos
self.__size = size
self.__color = color
self.__rect = pygame.Rect(pos.x, pos.y, size[0], size[1])
def getName(self) -> str:
return self.__name
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 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

View File

@ -0,0 +1,53 @@
import pygame
from Classes.Objects.BoardField import BoardField
class World():
__boardFields:list
__cardWidth:int = 200
__cardHeight:int = 250
__cardOffset:int = 400
def __init__(self, cardWidth:int=200, cardHeight:int=250, cardOffset:int=400):
self.__boardFields = []
self.__cardWidth = cardWidth
self.__cardHeight = cardHeight
self.__cardOffset = cardOffset
self.buildGameWorld()
def buildGameWorld(self):
# TODO: rebuild these to use the BoardField Class and to append them to the __boardFields list
# construct elements arround the playerfield
# Todo add lifepoint label for player and enemy and make them scriptable
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), 15)
self.__boardFields.append(BoardField("EnemyDeck", "Deck", pVector, (self.__cardWidth, self.__cardHeight), (0,255,0)))
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), (self.__cardHeight + 25))
self.__boardFields.append(BoardField("EnemyGraveyard", "Grave", pVector, (self.__cardWidth, self.__cardHeight), (0,255,0)))
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), ((2 * self.__cardHeight) + 60))
self.__boardFields.append(BoardField("PlayerDeck", "Deck", pVector, (self.__cardWidth, self.__cardHeight), (255,0,0)))
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), ((2 * self.__cardHeight) + self.__cardHeight + 70))
self.__boardFields.append(BoardField("PlayerGraveyard", "Grave", pVector, (self.__cardWidth, self.__cardHeight), (255,0,0)))
for i in range(5):
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * i)), ((2 * self.__cardHeight) + 60))
self.__boardFields.append(BoardField("PlayerMonsterField-"+str(i),"MonsterField",pVector,(self.__cardWidth, self.__cardHeight),(255,255,255)))
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * i)), ((2 * self.__cardHeight) + self.__cardHeight + 70))
self.__boardFields.append(BoardField("PlayerMonsterField-"+str(i), "EffectField", pVector, (self.__cardWidth, self.__cardHeight), (255,255,255)))
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * (i+1)), 15), (self.__cardWidth, self.__cardHeight))
self.__boardFields.append(BoardField("EnemyMonsterField-"+str(i), "MonsterField", pVector, (self.__cardWidth, self.__cardHeight), (255,255,255)))
pVector = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * (i+1))), (self.__cardHeight + 25))
self.__boardFields.append(BoardField("EnemySpellTrapField-"+str(i), "EffectField", pVector, (self.__cardWidth, self.__cardHeight), (255,255,255)))
def getBoardFields(self) -> list:
return self.__boardFields
def getCardWidth(self) -> int:
return self.__cardWidth
def getCardHeifht(self) -> int:
return self.__cardHeight