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
|
||||
|
||||
class BoardField():
|
||||
class BoardField(pygame.sprite.Sprite):
|
||||
__name:str
|
||||
__side:str
|
||||
__type:str
|
||||
__pos:pygame.Vector2
|
||||
__size:tuple
|
||||
__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.__side = side
|
||||
self.__type = type
|
||||
self.__pos = pos
|
||||
self.__size = size
|
||||
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:
|
||||
return self.__name
|
||||
@ -37,7 +41,10 @@ class BoardField():
|
||||
return self.__color
|
||||
|
||||
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:
|
||||
self.__name = name
|
||||
|
@ -15,17 +15,15 @@ class World():
|
||||
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
|
||||
pRow1Height = ((2 * self.__cardHeight) + 60)
|
||||
pRow2Height = ((2 * self.__cardHeight) + self.__cardHeight + 70)
|
||||
eRow1Height = 15
|
||||
eRow2Height = (self.__cardHeight + 25)
|
||||
eRow1Height = 105
|
||||
eRow2Height = (self.__cardHeight + 110)
|
||||
pRow1Height = ((2 * self.__cardHeight) + 145)
|
||||
pRow2Height = ((2 * self.__cardHeight) + self.__cardHeight + 150)
|
||||
|
||||
|
||||
eDeckPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), 15)
|
||||
eGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), (self.__cardHeight + 25))
|
||||
eDeckPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), eRow1Height)
|
||||
eGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 0)), eRow2Height)
|
||||
pGravePos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * 5)), pRow1Height)
|
||||
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.getType() == "MonsterField" and card.getType() == "MonsterCard":
|
||||
# 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.rect.center = field.getRect().center
|
||||
# card.image = pygame.transform.scale(card.image, (field.getSize()[0] - 10, field.getSize()[1] - 10))
|
||||
card.rect.center = field.rect.center
|
||||
field.image = card.image.copy()
|
||||
card.setDragging(False)
|
||||
self.__window.getScreen().blit(card.image, field.getRect().center)
|
||||
# card.kill()
|
||||
|
||||
|
||||
elif event.type == pygame.MOUSEBUTTONUP:
|
||||
if event.button == 1: # Wenn linke Maustaste losgelassen wird
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user