예제 #1
0
    def __init__(self):

        # Call Screen constructor
        Screen.__init__(self)

        # Video settings button
        self.videoSettingsButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 25,
            (255, 255, 255),
            (0, 0, 0),
            "VIDEO SETTINGS",
        )

        # Back button
        self.mainMenuButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 30,
            (255, 255, 255),
            (0, 0, 0),
            "MAIN MENU",
        )

        # List of buttons
        self.buttonList.append(self.videoSettingsButton)
        self.buttonList.append(self.mainMenuButton)
예제 #2
0
    def __init__(self):

        # Call Screen constructor
        Screen.__init__(self)

        # Make connection to the server
        self.n = Network()
        self.n.connect()

        # Retrieve list of games from server
        self.buttonListSubset = []
        self.buttonList = []
        self.buttonListSlice = [0, 4]
        self.updateGameList()

        # Page navigator to go to next or previous page of active games
        self.pageNavigator = PageNavigator()
예제 #3
0
    def __init__(self):

        # Call screen constructor
        Screen.__init__(self)

        # Back button
        self.mainMenuButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 25,
            (255, 255, 255),
            (0, 0, 0),
            "MAIN MENU",
        )

        # Add buttons to list
        self.buttonList.append(self.mainMenuButton)
예제 #4
0
    def __init__(self):

        # Call Screen constructor
        Screen.__init__(self)

        # Host button
        self.hostButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 25,
            (255, 255, 255),
            (0, 0, 0),
            "HOST GAME",
        )

        # Back button
        self.mainMenuButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 80,
            (255, 255, 255),
            (0, 0, 0),
            "MAIN MENU",
        )

        # List of buttons
        self.buttonList.append(self.hostButton)
        self.buttonList.append(self.mainMenuButton)

        # Text box to enter game name
        self.textBox = TextBox(
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 30,
            200,
            50,
        )

        # Game mode incrementer
        gameModeOptions = ["Normal", "Jick"]
        self.gameModeIncrementer = Incrementer(gameModeOptions)
        INCREMENTER_X = (Resources.SCREEN_WIDTH / 2) - (
            self.gameModeIncrementer.incrementerWidth / 2
        )
        INCREMENTER_Y = 40
        self.gameModeIncrementer.setPos(INCREMENTER_X, INCREMENTER_Y)

        # Number of players incrementer
        numPlayersOptions = ["3", "4"]
        self.numPlayersIncrementer = Incrementer(numPlayersOptions)
        INCREMENTER_X = (Resources.SCREEN_WIDTH / 2) - (
            self.numPlayersIncrementer.incrementerWidth / 2
        )
        INCREMENTER_Y = 90
        self.numPlayersIncrementer.setPos(INCREMENTER_X, INCREMENTER_Y)

        # Score required to win incrementer
        scoreOptions = ["11", "21"]
        self.scoreOptionsIncrementer = Incrementer(scoreOptions)
        INCREMENTER_X = (Resources.SCREEN_WIDTH / 2) - (
            self.scoreOptionsIncrementer.incrementerWidth / 2
        )
        INCREMENTER_Y = 140
        self.scoreOptionsIncrementer.setPos(INCREMENTER_X, INCREMENTER_Y)

        # Flag to show textbox input error
        self.showError = False
예제 #5
0
    def __init__(self):
        Screen.__init__(self)

        # 504p button
        self.fiveOFourButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 135,
            (255, 255, 255),
            (0, 0, 0),
            "896 x 504",
        )

        # 648p button
        self.sixFourtyEightButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 80,
            (255, 255, 255),
            (0, 0, 0),
            "1152 x 648",
        )

        # 720p button
        self.sevenTwentyButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 25,
            (255, 255, 255),
            (0, 0, 0),
            "1280 x 720",
        )

        # Fullscreen button
        self.fullScreenButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 30,
            (255, 255, 255),
            (0, 0, 0),
            "FULLSCREEN",
        )

        # Back button
        self.mainMenuButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 85,
            (255, 255, 255),
            (0, 0, 0),
            "MAIN MENU",
        )

        # List of buttons
        self.buttonList.append(self.fiveOFourButton)
        self.buttonList.append(self.sixFourtyEightButton)
        self.buttonList.append(self.sevenTwentyButton)
        self.buttonList.append(self.fullScreenButton)
        self.buttonList.append(self.mainMenuButton)
예제 #6
0
    def __init__(
        self,
        username,
        isHost,
        gameName=None,
        gameKey=None,
        maxPlayers=None,
        gameMode=None,
        winningScore=None,
    ):
        Screen.__init__(self)

        # Set up connection to server
        self.n = Network()
        self.n.connect()

        # Tell the server to create/join the game and return player id
        if isHost:
            self.player = self.n.getPlayer(
                f"host/{gameName}/{maxPlayers}/{gameMode}/{winningScore}")
        else:
            self.player = self.n.getPlayer(f"join/{gameKey}")

        # Get the game from the server
        self.game = self.n.send("get")

        # Check if the game could be received from the server
        connectionAttempts = 0
        MAX_ATTMEPTS = 10000
        while self.game is None and connectionAttempts < MAX_ATTMEPTS:
            self.game = self.n.send("get")
            connectionAttempts += 1

        # Only initialize game screen objects if server connectino was succesful
        if self.game is not None:

            # Set player username
            self.game.players[self.player].username = username
            self.n.send("username: "******"S"

            self.scoreButton = Button(
                SCORE_BUTTON_WIDTH,
                SCORE_BUTTON_HEIGHT,
                SCORE_BUTTON_X,
                SCORE_BUTTON_Y,
                SCORE_BUTTON_COLOR,
                SCORE_BUTTON_TEXT_COLOR,
                SCORE_BUTTON_TEXT,
            )

            # Ten and Under Button
            TEN_AND_UNDER_BUTTON_WIDTH = 100
            TEN_AND_UNDER_BUTTON_HEIGHT = 100
            TEN_AND_UNDER_BUTTON_PADDING = 10
            TEN_AND_UNDER_BUTTON_X = (self.screen.get_width() /
                                      2) - (TEN_AND_UNDER_BUTTON_WIDTH / 2)
            TEN_AND_UNDER_BUTTON_Y = (
                (self.screen.get_height() / 2) -
                (TEN_AND_UNDER_BUTTON_HEIGHT / 2)) - (
                    TEN_AND_UNDER_BUTTON_HEIGHT + TEN_AND_UNDER_BUTTON_PADDING)
            TEN_AND_UNDER_BUTTON_COLOR = (255, 0, 0)
            TEN_AND_UNDER_BUTTON_TEXT_COLOR = (0, 0, 0)
            TEN_AND_UNDER_BUTTON_TEXT = "TEN\nAND\nUNDER"

            self.tenAndUnderButton = Button(
                TEN_AND_UNDER_BUTTON_WIDTH,
                TEN_AND_UNDER_BUTTON_HEIGHT,
                TEN_AND_UNDER_BUTTON_X,
                TEN_AND_UNDER_BUTTON_Y,
                TEN_AND_UNDER_BUTTON_COLOR,
                TEN_AND_UNDER_BUTTON_TEXT_COLOR,
                TEN_AND_UNDER_BUTTON_TEXT,
            )

            # List of all the buttons
            self.buttonList.append(self.scoreButton)
            self.buttonList.append(self.tenAndUnderButton)

            # Score screen
            self.scoreScreen = ScoreScreen()

            # Win Screen
            self.winScreen = WinScreen()

            self.showGameScreen = False
            self.showScoreScreen = False
            self.showWinScreen = False
            self.gameReady = False
예제 #7
0
    def __init__(self):

        # Call screen constructor
        Screen.__init__(self)

        # Host button
        self.hostButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 80,
            (255, 255, 255),
            (0, 0, 0),
            "HOST",
        )

        # Join button
        self.joinButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 25,
            (255, 255, 255),
            (0, 0, 0),
            "JOIN",
        )

        # Options button
        self.optionsButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 30,
            (255, 255, 255),
            (0, 0, 0),
            "OPTIONS",
        )

        # Quit button
        self.quitButton = Button(
            200,
            50,
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) + 85,
            (255, 255, 255),
            (0, 0, 0),
            "QUIT",
        )

        # Text botx to enter username
        self.textBox = TextBox(
            (Resources.SCREEN_WIDTH / 2) - 100,
            (Resources.SCREEN_HEIGHT / 2) - 135,
            200,
            50,
        )

        # Add buttons to button list
        self.buttonList.append(self.hostButton)
        self.buttonList.append(self.joinButton)
        self.buttonList.append(self.optionsButton)
        self.buttonList.append(self.quitButton)

        self.showError = False