made progress on card resizing
This commit is contained in:
parent
3279713778
commit
386aaddae3
BIN
Game_Client/Assets/Arena/field.png
Normal file
BIN
Game_Client/Assets/Arena/field.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 612 B |
@ -1,22 +1,26 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
class BoardField():
|
class BoardField(pygame.sprite.Sprite):
|
||||||
__name:str
|
__name:str
|
||||||
__side:str
|
__side:str
|
||||||
__type:str
|
__type:str
|
||||||
__pos:pygame.Vector2
|
__pos:pygame.Vector2
|
||||||
__size:tuple
|
__size:tuple
|
||||||
__color:tuple = (255,255,255)
|
__color:tuple = (255,255,255)
|
||||||
_rect:pygame.Rect
|
image:pygame.image
|
||||||
|
rect:pygame.rect
|
||||||
|
|
||||||
def __init__(self, name:str, side:str, type:str, pos:pygame.Vector2, size:tuple, color:tuple):
|
def __init__(self, name:str, side:str, type:str, pos:pygame.Vector2, size:tuple, color:tuple, imagePath:str="Assets/Arena/field.png"):
|
||||||
|
pygame.sprite.Sprite.__init__(self)
|
||||||
self.__name = name
|
self.__name = name
|
||||||
self.__side = side
|
self.__side = side
|
||||||
self.__type = type
|
self.__type = type
|
||||||
self.__pos = pos
|
self.__pos = pos
|
||||||
self.__size = size
|
self.__size = size
|
||||||
self.__color = color
|
self.__color = color
|
||||||
self.__rect = pygame.Rect(pos.x, pos.y, size[0], size[1])
|
self.image = pygame.image.load(imagePath).convert_alpha()
|
||||||
|
self.rect = self.image.get_rect()
|
||||||
|
self.rect.center = self.__pos
|
||||||
|
|
||||||
def getName(self) -> str:
|
def getName(self) -> str:
|
||||||
return self.__name
|
return self.__name
|
||||||
@ -37,7 +41,10 @@ class BoardField():
|
|||||||
return self.__color
|
return self.__color
|
||||||
|
|
||||||
def getRect(self) -> pygame.Rect:
|
def getRect(self) -> pygame.Rect:
|
||||||
return self.__rect
|
return self.rect
|
||||||
|
|
||||||
|
def getImage(self) -> pygame.image:
|
||||||
|
return self.image
|
||||||
|
|
||||||
def setName(self, name:str) -> str:
|
def setName(self, name:str) -> str:
|
||||||
self.__name = name
|
self.__name = name
|
||||||
|
@ -15,17 +15,15 @@ class World():
|
|||||||
self.buildGameWorld()
|
self.buildGameWorld()
|
||||||
|
|
||||||
def buildGameWorld(self):
|
def buildGameWorld(self):
|
||||||
# TODO: rebuild these to use the BoardField Class and to append them to the __boardFields list
|
|
||||||
# construct elements arround the playerfield
|
# construct elements arround the playerfield
|
||||||
# Todo add lifepoint label for player and enemy and make them scriptable
|
# Todo add lifepoint label for player and enemy and make them scriptable
|
||||||
pRow1Height = ((2 * self.__cardHeight) + 60)
|
eRow1Height = 105
|
||||||
pRow2Height = ((2 * self.__cardHeight) + self.__cardHeight + 70)
|
eRow2Height = (self.__cardHeight + 110)
|
||||||
eRow1Height = 15
|
pRow1Height = ((2 * self.__cardHeight) + 145)
|
||||||
eRow2Height = (self.__cardHeight + 25)
|
pRow2Height = ((2 * self.__cardHeight) + self.__cardHeight + 150)
|
||||||
|
|
||||||
|
eDeckPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), eRow1Height)
|
||||||
eDeckPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), 15)
|
eGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), eRow2Height)
|
||||||
eGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), (self.__cardHeight + 25))
|
|
||||||
pGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), pRow1Height)
|
pGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), pRow1Height)
|
||||||
pDeckPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), pRow2Height)
|
pDeckPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), pRow2Height)
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -74,10 +74,12 @@ class App:
|
|||||||
if field.getSide() == "Player":
|
if field.getSide() == "Player":
|
||||||
if field.getType() == "MonsterField" and card.getType() == "MonsterCard":
|
if field.getType() == "MonsterField" and card.getType() == "MonsterCard":
|
||||||
# todo: resize card so that it fits into the card field
|
# todo: resize card so that it fits into the card field
|
||||||
pygame.transform.scale(card.image,(int((field.getRect().width - 10)),int((field.getRect().height - 10))))
|
# card.image = pygame.transform.scale(card.image, (field.getSize()[0] - 10, field.getSize()[1] - 10))
|
||||||
card.rect.center = field.getRect().center
|
card.rect.center = field.rect.center
|
||||||
|
field.image = card.image.copy()
|
||||||
card.setDragging(False)
|
card.setDragging(False)
|
||||||
self.__window.getScreen().blit(card.image, field.getRect().center)
|
# card.kill()
|
||||||
|
|
||||||
|
|
||||||
elif event.type == pygame.MOUSEBUTTONUP:
|
elif event.type == pygame.MOUSEBUTTONUP:
|
||||||
if event.button == 1: # Wenn linke Maustaste losgelassen wird
|
if event.button == 1: # Wenn linke Maustaste losgelassen wird
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user