wip: add multiplayer screen

This commit is contained in:
2021-07-09 09:13:14 -04:00
parent 4e1c3a7eee
commit f363b943e3
3 changed files with 16 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import sys
from tetri5.online import MultiplayerService
import pygame
from tetri5.util import ConfigurationManager
from tetri5.util import TextGenerator
@@ -41,6 +42,7 @@ class Game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
MultiplayerService.quit()
sys.exit()
@classmethod

View File

@@ -39,7 +39,7 @@ class MultiplayerService():
_NetworkConnectionService.close_connection()
class _NetworkConnectionService():
_URI = "ws://localhost:5001" # TODO get from config file
_URI = "ws://webapi.tetri5.com" # TODO get from config file
_websocket = None
_is_closed = False
_join_game = False

View File

@@ -8,6 +8,7 @@ from tetri5.util import SoundManager
from tetri5.entity import Well
from tetri5.entity import Stack
from tetri5.entity import PieceGenerator
from tetri5.online import MultiplayerService
"""
TODO
@@ -71,7 +72,7 @@ class TitleScene(Scene):
self._cursor_off = not self._cursor_off
if Controller.key_pressed(pygame.K_RETURN):
self._change_scence(SinglePlayerScene(self._change_scence)) # TODO implement multiplayer
self._change_scence(SinglePlayerScene(self._change_scence) if not self._is_multiplayer else MultiPlayerScene(self._change_scence))
"""
TODO
@@ -166,4 +167,14 @@ class SinglePlayerScene(Scene):
TODO
"""
class MultiPlayerScene(Scene):
pass
def __init__(self, change_scene: FunctionType) -> None:
self._tile_size = ConfigurationManager.get("engine", "tile-size")
self._background_color = pygame.Color(ConfigurationManager.get("color", "window-bg"))
MultiplayerService.init()
def draw(self, surface: pygame.Surface) -> None:
surface.fill(self._background_color)
def update(self, elapsed_time: int) -> None:
pass