added clientside placecard event
This commit is contained in:
@ -28,9 +28,8 @@ class BoardField(pygame.sprite.Sprite):
|
||||
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
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.center = self.__pos
|
||||
|
||||
def getName(self) -> str:
|
||||
return self.__name
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,8 @@ def PlaceCard(tcpClient, card):
|
||||
"event":"placecard",
|
||||
"card": card.getID(),
|
||||
"type": card.getType(),
|
||||
"pos": card.getPos(),
|
||||
"x": card.getPos().x,
|
||||
"y": card.getPos().y,
|
||||
}
|
||||
|
||||
tcpClient.send(payload)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -47,12 +47,12 @@ class App:
|
||||
# create sprite groups
|
||||
# todo: remove these and let server handle card creation instead
|
||||
# blocker: server - client communication [WIP]
|
||||
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(500, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(600, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(700, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(800, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(900, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(1000, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(500, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(600, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(700, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(800, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(900, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(1000, 1050), self.__inputHandler, Player(1000, 0, "test"))
|
||||
|
||||
while self.__running:
|
||||
self.__clock.tick(self.__FPS)
|
||||
@ -116,11 +116,11 @@ class App:
|
||||
mouse_pos = pygame.Vector2(mouse_x, mouse_y)
|
||||
if event.button == 1: # Wenn linke Maustaste losgelassen wird
|
||||
for card in self.__world.getCards():
|
||||
card.setDragging(False)
|
||||
card.setState("placed")
|
||||
# TODO: send place card event to server
|
||||
# resets the currently selected card in order to prevent it getting moved
|
||||
try:
|
||||
card.setDragging(False)
|
||||
card.setState("placed")
|
||||
# TODO: send place card event to server
|
||||
# resets the currently selected card in order to prevent it getting moved
|
||||
PlaceCard(self.__tcpClient, card) # tells the server that the player placed this card
|
||||
except Exception as e:
|
||||
print(f"failed to place card on server due to error: {e}")
|
||||
|
@ -16,10 +16,14 @@ class Window:
|
||||
self.__height = height
|
||||
self.__title = title
|
||||
|
||||
self.__screen = pygame.display.set_mode((self.__width, self.__height), pygame.FULLSCREEN)
|
||||
pygame.display.init()
|
||||
pygame.init()
|
||||
|
||||
pygame.display.set_caption = self.__title
|
||||
self.__screen = pygame.display.set_mode((self.__width, self.__height))
|
||||
self.__screen.fill((236, 240, 241)) # Hier liegt der Fehler, es muss eine Tuple übergeben werden
|
||||
pygame.display.set_caption(self.__title)
|
||||
|
||||
self.__clock = pygame.time.Clock()
|
||||
self.__framerate = 60 # Framerate auf 60 FPS festlegen
|
||||
|
||||
# set framerate (where the fuck is it?)
|
||||
def Render(self):
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user