Beispiel #1
0
 def __init__(self):
     pg.init()
     self.rows = 60
     self.columns = 40
     self.screen = pg.display.set_mode(
         (self.rows * 10, self.columns * 10 + 20))
     self.width, self.height = self.screen.get_size()
     self.screen_rect = self.screen.get_rect()
     self.done = False
     self.pause = True
     self.clock = pg.time.Clock()
     self.fps = 60
     self.color = pg.Color('white')
     self.title = pg.display.set_caption(
         'Conway\'s Game of Life (by void*)')
     self.start_button = Button((self.width - self.width, self.height - 20,
                                 self.width / 3 - 10, 20), 'gray', 'Start',
                                'black')
     self.pause_button = Button((self.width / 2 - self.width / 3 / 2 + 5,
                                 self.height - 20, self.width / 3 - 10, 20),
                                'gray', 'Pause', 'black')
     self.reset_button = Button((self.width - self.width / 3 + 10,
                                 self.height - 20, self.width / 3 - 10, 20),
                                'gray', 'Reset', 'black')
     self.cells = []
     self.last_updated_cell = None
     self.setupCells()
Beispiel #2
0
    def initOverlay(self):
        textFont = Fonts.getFont(Fonts.Courier, 30)
        window = self.window
        width, height = self.app.width, self.app.height

        unit = height / 4

        self.volumeButton = ImageButton(window,
                                        2 * width / 3,
                                        1.6 * unit,
                                        Assets.assets["volume_on"],
                                        fillColor=Colors.WHITE)
        self.volumeButton.setOnClickListener(self.toggleVolume)

        self.respawnButton = Button(window,
                                    width / 2,
                                    2 * unit,
                                    font=textFont,
                                    text="Respawn",
                                    fillColor=Colors.WHITE,
                                    padding=10)
        self.respawnButton.setOnClickListener(self.respawnPlayer)

        self.resumeButton = Button(window,
                                   width / 2,
                                   2 * unit,
                                   font=textFont,
                                   text="Resume Game",
                                   fillColor=Colors.WHITE,
                                   padding=10)
        self.resumeButton.setOnClickListener(self.togglePause)

        self.difficultyButton = Button(window,
                                       width / 2,
                                       2.5 * unit,
                                       font=textFont,
                                       text="Difficulty: Normal",
                                       fillColor=Colors.WHITE,
                                       padding=10)
        self.difficultyButton.setOnClickListener(self.cycleDifficulty)

        self.quitButton = Button(window,
                                 width / 2,
                                 3 * unit,
                                 font=textFont,
                                 text="Main Menu",
                                 fillColor=Colors.WHITE,
                                 padding=10)
        self.quitButton.setOnClickListener(self.quit)

        self.overlayComponents = [
            self.resumeButton, self.quitButton, self.respawnButton,
            self.volumeButton, self.difficultyButton
        ]

        for component in self.overlayComponents:
            component.setEnabled(False)

        self.addComponents(self.overlayComponents)
Beispiel #3
0
    def __init__(self, root: Panel):
        """Create a new MainMenuScene, creating the gui components to
        display.
        """
        size = root.get_rect().size
        title_rect = Rect(0, 0, 500, 70)
        title_rect.center = (size[0] / 2, size[1] / 2 - 200)

        # A panel for all the options
        options_panel = VerticalPanel(rect=Rect(size[0] / 4, size[1] / 2,
                                                size[0] / 2, size[1] / 4),
                                      expand_height=False,
                                      parent=root)

        # Title label
        Label(text="BATTLE SHIP!",
              rect=title_rect,
              style=Style(background_color=None,
                          border_width=0,
                          font=pygame.font.Font('freesansbold.ttf', 64),
                          primary_color=(255, 255, 255)),
              parent=root)

        # A style for all of the menu options
        button_style = Style(primary_color=(255, 255, 255),
                             background_color=(128, 0, 0),
                             border_width=1,
                             border_color=(0, 0, 0),
                             font=pygame.font.Font('freesansbold.ttf', 32))

        # Player vs Computer button
        Button(rect=Rect(0, 0, 400, 40),
               on_click=self._pvc_clicked,
               text="Player vs Computer",
               style=button_style,
               parent=options_panel)

        # Player vs Player button
        Button(rect=Rect(0, 0, 400, 40),
               on_click=self._pvp_clicked,
               text="Player vs Player",
               style=button_style,
               parent=options_panel)

        # Settings button
        Button(rect=Rect(0, 0, 400, 40),
               on_click=self._settings_clicked,
               text="Settings",
               style=button_style,
               parent=options_panel)

        # Quit button
        Button(rect=Rect(0, 0, 400, 40),
               on_click=self._quit_clicked,
               text="Quit",
               style=button_style,
               parent=options_panel)
def run_game():
    # 初始化游戏并创建一个屏幕对象
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height)
    )
    pygame.display.set_caption("Alien Invasion")

    # 创建Play按钮
    play_button = Button(ai_settings, screen, "Play")

    # 创建统计信息实例
    stats = GameStats(ai_settings)
    sb = ScoreBoard(ai_settings, screen, stats)

    # 创建一艘飞船
    ship = Ship(ai_settings, screen)
    # 创建一个用于存储子弹的编组
    bullets = Group()
    # 创建一个外星人编组
    aliens = Group()

    # 创建外星人群
    gf.creat_fleet(ai_settings, screen, aliens, ship)

    # 开始游戏的主循环
    while True:
        gf.check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets)
        if stats.game_active:
            ship.update()
            gf.update_bullets(ai_settings, screen, stats, sb, ship, bullets, aliens)
            gf.update_aliens(ai_settings, stats, screen, sb, ship, aliens, bullets)

        gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button)
Beispiel #5
0
    def initComponents(self):
        textFont = Fonts.getFont(Fonts.Courier, 30)
        window = self.window
        height, width = self.app.height, self.app.width
        title = Label(window, width/2, 0.5*height/3,
                            font=textFont, text="Load World")

        self.worldButtons = []
        y = [1.8, 2.5, 3.2]
        for i in range(3):
            button = Button(window, width/2, y[i]*height/4,
                            font=textFont, text="New World",
                            padding=10, fillColor=Colors.WHITE)
            button.setOnClickListener(self.loadWorld, i)
            self.worldButtons.append(button)

        self.deleteButtons = []
        for i in range(3):
            button = self.worldButtons[i]
            imgButton = ImageButton(window, width/2 + button.width, y[i]*height/4,
                                 Assets.assets["delete"], padding=10, borderWidth=0)
            imgButton.setOnClickListener(self.deleteWorld, i)
            self.deleteButtons.append(imgButton)

        self.addComponents(self.worldButtons)
        self.addComponents(self.deleteButtons)
        self.addComponent(title)
Beispiel #6
0
    def init_buttons(self):
        self.btn_back = Button('pause-screen', (self.max_witdh, 50),
                               bg=(80, 80, 80),
                               fg=(50, 50, 50),
                               text=Text('Back', color=COLOR_WHITE),
                               on_left_click=self.load_prev)

        self.btn_menu = Button('pause-screen', (self.max_witdh, 50),
                               bg=(80, 80, 80),
                               fg=(50, 50, 50),
                               text=Text('Main Menu', color=COLOR_WHITE),
                               on_left_click=self.load_menu)

        self.btn_quit = Button('pause-screen', (self.max_witdh, 50),
                               bg=(80, 80, 80),
                               fg=(50, 50, 50),
                               text=Text('Quit', color=COLOR_WHITE),
                               on_left_click=quit_game)
    def __init__(self, position, navigator, client):
        GameObject.__init__(self, position)
        self.position = position
        self.cells = []
        self.navigator = navigator
        self.client = client

        self.gif = Gif((self.position[0] - 140, self.position[1] - 20), 'tenor.gif')
        self.button = Button((self.position[0], self.position[1] + 350), 75, 'Continuar', self.on_confirm)
        self.text = Text((self.position[0], self.position[1] - 100), 100, 'Parabéns, você venceu!')
Beispiel #8
0
    def create_buttons(self, root: Component) -> None:
        """Create all buttons in the settings menu"""

        button_style = Style(background_color=(0, 255, 255),
                             primary_color=(0, 0, 0),
                             border_color=(0, 0, 0),
                             border_width=1)

        size = sm.SceneManager.instance.get_screen_size()
        self.back_button = Button(on_click=self._open_main_menu,
                                  rect=Rect(20, 20, 100, 100),
                                  style=Style(
                                      background_color=(255, 0, 0),
                                      background_image=pygame.image.load(
                                          "images/left-arrow-icon.png")),
                                  parent=root)

        self.fullscreen_button = Button(on_click=self._toggle_fullscreen,
                                        text=self._get_window_mode_text(),
                                        rect=Rect(450, 320, 150, 50),
                                        style=button_style,
                                        parent=self.window_mode_panel)
Beispiel #9
0
    def startup(self, persistent):
        pygame.mouse.set_visible(True)
        self.button_list = pygame.sprite.Group()

        start_button = Button((WIDTH / 2 - 50),
                              HEIGHT / 1.75,
                              100,
                              40,
                              self.end,
                              text="PLAY",
                              font=pygame.font.Font('freesansbold.ttf',
                                                    20)).add(self.button_list)

        super().startup(persistent)
    def __init__(self, position, navigator, client):
        GameObject.__init__(self, position)
        self.position = position
        self.cells = []
        self.navigator = navigator
        self.client = client

        self.gif = Gif((self.position[0] - 280, self.position[1] - 200),
                       'address.gif')
        self.button = Button((self.position[0], self.position[1] + 320), 75,
                             'Connectar', self.on_connect)
        self.text = Text((self.position[0] - 200, self.position[1] + 212), 100,
                         'Endereço:')
        self.text_input = TextInput(
            (self.position[0] - 50, self.position[1] + 200), 100)
    def __init__(self, position, ip, navigator, client):
        GameObject.__init__(self, position)
        self.position = position
        self.ip = ip
        self.cells = []
        self.navigator = navigator
        self.client = client

        self.gif = Gif((self.position[0] - 170, self.position[1] - 200),
                       'port.gif')
        self.button = Button((self.position[0], self.position[1] + 320), 75,
                             'Connectar', self.on_connect)
        self.text = Text((self.position[0] - 200, self.position[1] + 212), 100,
                         'Porta:')
        self.text_input = TextInput(
            (self.position[0] - 50, self.position[1] + 200), 100)
Beispiel #12
0
    def init_buttons(self):
        self.game = Button('menu', ((305 / 1024.0) * SCREEN_SIZE.W,
                                    (305 / 768.0) * SCREEN_SIZE.H),
                           bg=pygame.image.load('menu/g.png'),
                           fg=pygame.image.load('menu/gf.png'),
                           on_left_click=lambda: load_game(1))

        self.btn_1 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g1.png'),
                            fg=pygame.image.load('menu/g1f.png'),
                            text=Text('Game 1'),
                            on_left_click=lambda: load_game(1))

        self.btn_2 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g2.png'),
                            fg=pygame.image.load('menu/g2f.png'),
                            text=Text('Game 2'),
                            on_left_click=lambda: load_game(2))

        self.btn_3 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g3.png'),
                            fg=pygame.image.load('menu/g3f.png'),
                            text=Text('Game 3'),
                            on_left_click=lambda: load_game(3))

        self.btn_4 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g4.png'),
                            fg=pygame.image.load('menu/g4f.png'),
                            text=Text('Game 4'))

        self.btn_5 = Button('menu', ((143 / 1024.0) * SCREEN_SIZE.W,
                                     (143 / 768.0) * SCREEN_SIZE.H),
                            bg=pygame.image.load('menu/g5.png'),
                            fg=pygame.image.load('menu/g5f.png'),
                            text=Text('Game 5'))

        self.profile = Button('menu', ((467 / 1024.0) * SCREEN_SIZE.W,
                                       (92 / 768.0) * SCREEN_SIZE.H),
                              bg=pygame.image.load('menu/p.png'),
                              fg=pygame.image.load('menu/pf.png'),
                              text=Text('VIEW MY PROFILE'))
Beispiel #13
0
    def __init__(self, top):
        super().__init__()
        self.top = top
        self.setup_ui()
        self.scan_thread = None

        layout = Qt.QGridLayout()

        self.prop_layout = Qt.QVBoxLayout()
        # props
        self.scan()

        # button
        button_layout = Qt.QHBoxLayout()
        self.button_rescan = Button(self, '刷新', lambda e: self.scan())
        button_layout.addWidget(self.button_rescan)

        layout.addLayout(self.prop_layout, 0, 0)
        layout.addLayout(button_layout, 1, 0)
        self.setLayout(layout)
        self.show_at_center()
Beispiel #14
0
    def __init__(self, window, element=[], style={}, parent=None):

        self.window = window
        self.parent = parent

        #super().__init__(style)

        menu = View(self.window, style=style, parent=parent)
        layer = View(self.window,
                     style={
                         "width": "5%",
                         "background": (112, 109, 90),
                     },
                     parent=menu)
        overflow = View(self.window,
                        style={
                            "width": "20%",
                            "left": "60%",
                            "background": (141, 138, 119),
                        },
                        parent=layer)

        nbr = len(element)
        self.buttons = []
        size = int(parent.position[3] * 100 / nbr / parent.position[3] -
                   (nbr - 1))
        for i in range(nbr):
            self.buttons.append(
                Button(window,
                       element[i][0],
                       style={
                           "width": "90%",
                           "left": "10%",
                           "height": str(size) + "%",
                           "top": str(size * i + i * nbr) + "%",
                           "background": (137, 134, 115),
                           "after-color": (37, 37, 25)
                       },
                       parent=menu,
                       callback=element[i][1]))
Beispiel #15
0
# from utils.pinout import set_pinout
# pinout = set_pinout()

# --- leds ---

from components.led import Led

led2 = Led(16)  # PWM2
led3 = Led(25)  # PWM3

# --- buttons ---
from machine import Pin
from components.button import Button

boot_pin = Pin(0, Pin.IN)
boot_button = Button(boot_pin, release_value=1)

pin34 = Pin(34, Pin.IN)
pin35 = Pin(35, Pin.IN)
# pin36 = Pin(36, Pin.IN)
# pin39 = Pin(39, Pin.IN)
right_button = Button(pin35, release_value=1)
left_button = Button(pin34, release_value=1)

# --- relay ---
relay = Led(17)  # PWM1

# --- oled ---
# I2C oled display
from utils.octopus import oled_init
from components.oled import threeDigits
Beispiel #16
0
def start():
    pygame.init()

    json_file = open(os.getcwd() + r"\components\constants.json", "r")
    json_content = json.load(json_file)
    round_int = json_content["round_int"]
    json_file.close()

    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    BROWN = (138, 79, 28)
    font_large = pygame.font.SysFont("DejaVu Sans", 30)
    font_small = pygame.font.SysFont("DejaVu Sans", 22)

    screen = pygame.display.set_mode((720, 480))
    screen.fill(BROWN)

    clock = pygame.time.Clock()

    choose_label = font_large.render("Choose a gamemode", 1, BLACK)
    screen.blit(choose_label, (200, 60))

    bot_box = TickBox(posx=320, posy=350, size=30)
    button_standard = Button(
        x=100,
        y=200,
        w=200,
        h=100,
        color_b=BLACK,
        color_in=WHITE,
        color_t=WHITE,
        command=lambda:
        [intermediary(bot=bot_box.getStatus(), mode="STANDARD")],
        text='STANDARD')

    button_960 = Button(
        x=400,
        y=200,
        w=200,
        h=100,
        color_b=BLACK,
        color_in=WHITE,
        color_t=WHITE,
        command=lambda:
        [intermediary(bot=bot_box.getStatus(), mode="CHESS 960")],
        text='CHESS 960')

    bot_label = font_small.render("Play against AI", 1, BLACK)
    screen.blit(bot_label, (120, 350))

    items = [button_standard, button_960, bot_box]
    for item in items:
        item.draw(screen=screen)
    pygame.display.update()

    while True:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                quit()

            for item in items:
                item.processEvent(event)

            bot_box.draw(screen)

        pygame.display.flip()
Beispiel #17
0
def login(mode='STANDARD'):
    pygame.init()

    json_file = open(os.getcwd() + r"\components\constants.json", "r")
    json_content = json.load(json_file)
    round_int = json_content["round_int"]
    json_file.close()

    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    BROWN = (138, 79, 28)
    font = pygame.font.SysFont("DejaVu Sans", 30)
    # RED = (255, 0, 0), GREEN = (0, 255, 0), BLUE = (0, 0, 255)

    screen = pygame.display.set_mode((720, 480))
    screen.fill(BROWN)

    clock = pygame.time.Clock()

    pygame.display.update()

    title_label = font.render(mode, True, BLACK)

    Player1_label = font.render("Player 1:", True, BLACK)
    Player2_label = font.render("Player 2:", True, BLACK)

    Player1 = InputBox(300, 200, 100, 32, WHITE, (10, 10, 10))
    Player2 = InputBox(300, 250, 100, 32, WHITE, (10, 10, 10))

    Accept_Button = Button(x=300,
                           y=300,
                           w=100,
                           h=50,
                           color_b=BLACK,
                           color_in=WHITE,
                           color_t=WHITE,
                           command=lambda: [
                               main(player1=Player1.export(),
                                    player2=Player2.export(),
                                    mode=mode,
                                    bot_bool=False)
                           ],
                           text='Start Game')

    boxes_arr = [Player1, Player2]

    while True:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                quit()

            for box in boxes_arr:
                box.checkActivation(event)

            Accept_Button.processEvent(event)

            screen.fill(BROWN)
            screen.blit(Player1_label, (150, 200))
            screen.blit(Player2_label, (150, 250))
            screen.blit(title_label, (pygame.display.get_window_size()[0] / 2 -
                                      title_label.get_rect().w / 2, 30))
            for box in boxes_arr:
                box.draw(screen)

            Accept_Button.draw(screen)

            pygame.display.flip()
Beispiel #18
0
from components.rotary_encoder.rotary_irq import RotaryIRQ
from components.button import Button

print("simple test: rotary encoder and oled display")
oled = oled_init()
oled.clear()
oled.text("octopusLAB 2020", 3, 1)
oled.show()

#               ROBOTboard
ROT_SW = 13  # MOTOR_34EN
ROT_DT = 25  # MOTOR_12EN
ROT_CLK = 26  # MOTOR_1A

#sw = button_init(ROT_SW)
rot_button = Button(ROT_SW, release_value=1)
rot = RotaryIRQ(pin_num_clk=ROT_CLK,
                pin_num_dt=ROT_DT,
                min_val=0,
                max_val=5,
                reverse=False,
                range_mode=RotaryIRQ.RANGE_WRAP)


@rot_button.on_press
def on_press_button():
    global st
    print("btn")
    st = 500
    oled.oledSegment(oled, st)
Beispiel #19
0
    def _init_components(self):
        background_color = self.get_background()
        scrollbar_width = SCROLL_BAR_WIDTH
        height_buttons = BUTTON[1] + PADDING * 2
        width_buttons = BUTTON[1] + PADDING * 2

        self.button_back = ButtonBack(self,
                                      size=height_buttons,
                                      onClick=self.navigate_home)

        self.label_logo = Label(self)
        self.label_logo.config(
            text="weCoNet",
            font=LOGO,
            background=background_color,
            foreground=BLUE,
        )

        self.label_queries = Label(self)
        self.label_queries.config(text="QUERIES",
                                  font=BODY_BOLD,
                                  background=background_color,
                                  foreground=BLACK,
                                  anchor="nw")
        """
        ScrollView result     
        """
        self.canvas_queries = Canvas(
            self,
            highlightthickness=1,
        )
        self.frame_queries = Frame(
            self.canvas_queries,
            highlightthickness=1,
            #    borderwidth=1,
            #    relief="solid",
        )
        self.canvas_queries.config(
            background=WHITE,
            highlightthickness=0,
        )
        self.frame_queries.config(
            background=WHITE,
            highlightthickness=0,
        )

        self.scrollbar_queries = Scrollbar(self,
                                           orient="vertical",
                                           width=scrollbar_width,
                                           command=self.canvas_queries.yview)
        self.canvas_queries.config(yscrollcommand=self.scrollbar_queries.set, )

        self.canvas_queries.create_window(
            (0, 0),
            window=self.frame_queries,
            anchor="nw",
        )

        self.frame_queries.bind("<Configure>", self._onFrameConfigure)

        self.list_card_recommendation = None

        self.button_add = Button(self,
                                 self.app.width - PADDING * 2,
                                 height=height_buttons,
                                 text="See more ...",
                                 enable=True,
                                 onClick=self._on_click_see_more)
Beispiel #20
0
#  running TM from source programs_turing/program_xxx.txt

from time import sleep
from uturing import TuringMachine, run_src
from components.button import Button
from components.rgb import Rgb
import colors_rgb as rgb
import pubsub
# from utils.octopus import disp7_init

from machine import Pin
button0 = Button(Pin(0), release_value=1)

# d7 = disp7_init()  # 8 x 7segment display init
ws_num = 32
ws = Rgb(15, ws_num)
ws.simpleTest()

c1 = (32, 8, 0)
c0 = (0, 16, 0)

print()
print("Turing Machine Emulator (ESP32 - Micropython)")


def ws_clear_all(num=ws_num):
    for i in range(num):
        ws.color(rgb.BLACK, i)


def ws_show_tape(tape, ofset=5):
Beispiel #21
0
    def __init__(self, root: Panel):
        """Create a new GameScene, creating the gui components to
        display and starting the game.
        """
        self._pause_menu = PauseMenuPanel(Rect(0, 0, 0, 0),
                                          style=Style(
                                              background_color=None,
                                              border_width=0,
                                              force_parent_redraw=True))

        # A style for all
        button_style = Style(background_color=(0, 255, 255),
                             primary_color=(0, 0, 0),
                             border_color=(0, 0, 0),
                             border_width=1)

        size = root.get_rect().size

        rect1 = Rect(size[0] / 8, size[1] / 8, size[0] * 3 / 8,
                     size[1] * 3 / 4)
        rect2 = Rect(size[0] / 2, size[1] / 8, size[0] * 3 / 8,
                     size[1] * 3 / 4)

        # The background water for the game
        self._background_water = BackgroundWater(rect=Rect(
            0, 0, size[0], size[1]),
                                                 parent=root)

        # A style for for the pause button
        pause_style = Style(
            background_color=None,
            force_parent_redraw=True,
            border_color=(0, 0, 0),
            border_width=2,
            background_image=pygame.image.load("images/pause.jpg"))

        # Pause Button
        Button(on_click=self._pause_clicked,
               rect=Rect(20, 20, 100, 100),
               style=pause_style,
               parent=self._background_water)

        # A style for player 1 grids
        player1_grid_style = Style(background_color=None,
                                   primary_color=(255, 0, 0, 100),
                                   secondary_color=(0, 0, 0, 200),
                                   border_color=(0, 0, 0),
                                   border_width=1,
                                   force_parent_redraw=True)

        # Create player 1 grids
        self._player1_grids = self._create_player_grids(
            rect1, player1_grid_style)

        # A style for player 2 grids
        player2_grid_style = Style(background_color=None,
                                   primary_color=(0, 255, 0, 50),
                                   secondary_color=(0, 0, 0, 200),
                                   border_color=(0, 0, 0),
                                   border_width=1,
                                   force_parent_redraw=True)

        # Create player 2 grids
        self._player2_grids = self._create_player_grids(
            rect2, player2_grid_style)

        # Setup observers
        player1 = GameManager.instance.get_player1()
        player2 = GameManager.instance.get_player2()
        player1.clear_observers()
        player2.clear_observers()
        player1.add_observer(self)
        player2.add_observer(self)

        # Start the game
        current_player = GameManager.instance.get_whos_turn()
        current_player.on_turn_started()
        current_player.notify_observers()