switched up layout
This commit is contained in:
parent
5de6b06503
commit
a47d372053
Before Width: | Height: | Size: 612 B After Width: | Height: | Size: 612 B |
@ -1,4 +1,5 @@
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Test Monster",
|
||||
"image": "Assets/Cards/testmonstercard/cards.png",
|
||||
"description": "can attack other monsters",
|
||||
@ -6,14 +7,16 @@
|
||||
"defense": 40,
|
||||
"attacks":[
|
||||
{
|
||||
"id":1,
|
||||
"id": 1,
|
||||
"name":"test attack",
|
||||
"damage":80
|
||||
"description": "can attack another Monster",
|
||||
"damage": 80
|
||||
},
|
||||
{
|
||||
"id":2,
|
||||
"id": 2,
|
||||
"name":"test attack",
|
||||
"damage":80
|
||||
"description": "can attack another Monster",
|
||||
"damage": 80
|
||||
}
|
||||
]
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import pygame
|
||||
|
||||
class BoardField(pygame.sprite.Sprite):
|
||||
@ -7,18 +8,25 @@ class BoardField(pygame.sprite.Sprite):
|
||||
__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, size:tuple, color:tuple, imagePath:str="Assets/Arena/field.png"):
|
||||
def __init__(self, name:str, side:str, type:str, pos:pygame.Vector2, imagePath:str):
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
self.__name = name
|
||||
self.__side = side
|
||||
self.__type = type
|
||||
self.__pos = pos
|
||||
self.__size = size
|
||||
self.__color = color
|
||||
self.image = pygame.image.load(imagePath).convert_alpha()
|
||||
self.__holdsCard = None
|
||||
|
||||
# Überprüfen des Dateipfads
|
||||
if not os.path.exists(imagePath):
|
||||
print("Der Dateipfad zur Bilddatei ist ungültig oder die Datei existiert nicht.")
|
||||
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
|
||||
|
||||
@ -45,6 +53,9 @@ class BoardField(pygame.sprite.Sprite):
|
||||
|
||||
def getImage(self) -> pygame.image:
|
||||
return self.image
|
||||
|
||||
def getHoldingCard(self):
|
||||
return self.__holdsCard
|
||||
|
||||
def setName(self, name:str) -> str:
|
||||
self.__name = name
|
||||
@ -64,4 +75,7 @@ class BoardField(pygame.sprite.Sprite):
|
||||
|
||||
def setColor(self, color:tuple) -> tuple:
|
||||
self.__color = color
|
||||
return self.__color
|
||||
return self.__color
|
||||
|
||||
def setCardHolding(self, card):
|
||||
self.__holdsCard = card
|
@ -23,7 +23,7 @@ class MonsterCard(pygame.sprite.Sprite):
|
||||
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
|
||||
data = json.load(open(assetDir + "/testmonstercard.json"))
|
||||
data = json.load(open(assetDir + "/card.json"))
|
||||
self.__pos = pos
|
||||
self.__name = data["name"]
|
||||
self.image = pygame.image.load(assetDir + "/card.png").convert_alpha()
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,7 +7,7 @@ class World():
|
||||
__cardHeight:int = 200
|
||||
__cardOffset:int = 400
|
||||
|
||||
def __init__(self, cardWidth:int=150, cardHeight:int=200, cardOffset:int=400):
|
||||
def __init__(self, cardWidth:int=300, cardHeight:int=550, cardOffset:int=400):
|
||||
self.__boardFields = []
|
||||
self.__cardWidth = cardWidth
|
||||
self.__cardHeight = cardHeight
|
||||
@ -17,20 +17,20 @@ class World():
|
||||
def buildGameWorld(self):
|
||||
# construct elements arround the playerfield
|
||||
# Todo add lifepoint label for player and enemy and make them scriptable
|
||||
eRow1Height = 105
|
||||
eRow2Height = (self.__cardHeight + 110)
|
||||
pRow1Height = ((2 * self.__cardHeight) + 145)
|
||||
pRow2Height = ((2 * self.__cardHeight) + self.__cardHeight + 150)
|
||||
eRow1Height = 75
|
||||
eRow2Height = (self.__cardHeight + 35)
|
||||
pRow1Height = ((2 * self.__cardHeight) + 75)
|
||||
pRow2Height = ((2 * self.__cardHeight) + self.__cardHeight + 30)
|
||||
|
||||
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)
|
||||
|
||||
self.__boardFields.append(BoardField("EnemyDeck", "Enemy", "Deck", eDeckPos, (self.__cardWidth, self.__cardHeight), (0,255,0)))
|
||||
self.__boardFields.append(BoardField("EnemyGraveyard", "Enemy", "Grave", eGravePos, (self.__cardWidth, self.__cardHeight), (0,255,0)))
|
||||
self.__boardFields.append(BoardField("PlayerDeck", "Player", "Deck", pDeckPos, (self.__cardWidth, self.__cardHeight), (255,0,0)))
|
||||
self.__boardFields.append(BoardField("PlayerGraveyard", "Player", "Grave", pGravePos, (self.__cardWidth, self.__cardHeight), (255,0,200)))
|
||||
self.__boardFields.append(BoardField("EnemyDeck", "Enemy", "Deck", eDeckPos, (self.__cardWidth, self.__cardHeight), "Assets/Cards/Arena/field.png"))
|
||||
self.__boardFields.append(BoardField("EnemyGraveyard", "Enemy", "Grave", eGravePos, (self.__cardWidth, self.__cardHeight), "Assets/Cards/Arena/field.png"))
|
||||
self.__boardFields.append(BoardField("PlayerDeck", "Player", "Deck", pDeckPos, (self.__cardWidth, self.__cardHeight), "Assets/Cards/Arena/field.png"))
|
||||
self.__boardFields.append(BoardField("PlayerGraveyard", "Player", "Grave", pGravePos, (self.__cardWidth, self.__cardHeight), "Assets/Cards/Arena/field.png"))
|
||||
|
||||
for i in range(5):
|
||||
pMonsterPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * i)), pRow1Height)
|
||||
@ -38,10 +38,10 @@ class World():
|
||||
eMonsterPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * (i+1)), eRow1Height))
|
||||
eEffectPos = pygame.Vector2((self.__cardOffset + ((self.__cardWidth + 10) * (i+1))), eRow2Height)
|
||||
|
||||
self.__boardFields.append(BoardField("PlayerMonsterField-"+str(i), "Player", "MonsterField", pMonsterPos, (self.__cardWidth, self.__cardHeight), (255,255,255)))
|
||||
self.__boardFields.append(BoardField("PlayerEffectField-"+str(i), "Player", "EffectField", pEffectPos, (self.__cardWidth, self.__cardHeight), (255,255,255)))
|
||||
self.__boardFields.append(BoardField("EnemyMonsterField-"+str(i), "Enemy", "MonsterField", eMonsterPos, (self.__cardWidth, self.__cardHeight), (255,255,255)))
|
||||
self.__boardFields.append(BoardField("EnemySpellTrapField-"+str(i), "Enemy", "EffectField", eEffectPos, (self.__cardWidth, self.__cardHeight), (255,255,255)))
|
||||
self.__boardFields.append(BoardField("PlayerMonsterField-"+str(i), "Player", "MonsterField", pMonsterPos, "Assets/Cards/Arena/field.png"))
|
||||
self.__boardFields.append(BoardField("PlayerEffectField-"+str(i), "Player", "EffectField", pEffectPos, "Assets/Cards/Arena/field.png"))
|
||||
self.__boardFields.append(BoardField("EnemyMonsterField-"+str(i), "Enemy", "MonsterField", eMonsterPos, "Assets/Cards/Arena/field.png"))
|
||||
self.__boardFields.append(BoardField("EnemySpellTrapField-"+str(i), "Enemy", "EffectField", eEffectPos, "Assets/Cards/Arena/field.png"))
|
||||
|
||||
def getBoardFields(self) -> list:
|
||||
return self.__boardFields
|
||||
|
Binary file not shown.
Binary file not shown.
@ -74,7 +74,7 @@ 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
|
||||
card.image = pygame.transform.scale(card.image, (field.getSize()[0] - 10, field.getSize()[1] - 10))
|
||||
# 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)
|
||||
@ -86,16 +86,7 @@ class App:
|
||||
mouse_pos = pygame.Vector2(mouse_x, mouse_y)
|
||||
if event.button == 1: # Wenn linke Maustaste losgelassen wird
|
||||
for card in self.cards:
|
||||
if card.rect.collidepoint(mouse_pos):
|
||||
for field in self.__world.getBoardFields():
|
||||
if field.getRect().collidepoint(mouse_pos):
|
||||
# Überprüfe, ob das Spielfeld ein MonsterField und die Karte eine MonsterCard ist
|
||||
if field.getSide() == "Player" and field.getType() == "MonsterField" and card.getType() == "MonsterCard":
|
||||
# Setze die Karte zurück, wenn sie aus dem Spielfeld herausgezogen wird
|
||||
card.image = pygame.transform.scale(card.image, card.original_size)
|
||||
card.rect.center = card.original_position
|
||||
card.setDragging(False)
|
||||
break
|
||||
card.setDragging(False)
|
||||
|
||||
# sets the running state for the gameloop
|
||||
def setRunning(self, running:bool):
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user