int main(void) { auto renderWindow = CreateRenderWindow(); auto inputComponent = CreateInputHandler(renderWindow); auto gameBoard = CreateGameBoard(); const auto numTiles = gameBoard->GetNumTiles(); auto renderComponent = CreateGameRenderer(*gameBoard, renderWindow); auto boardController = std::make_unique<BoardController>(std::move(gameBoard)); auto playerController = CreatePlayerController(NUM_PLAYERS); { auto chooser = std::make_shared<TileChooser>(NUM_PLAYERS, 10, *renderComponent); inputComponent->AddObserver(chooser); chooser->ChooseTiles(); //chooser->AutoChooseTiles(); chooser->AssignTilesToPlayers(*playerController); } { auto manager = std::make_shared<GameManager>(std::move(renderComponent), std::move(boardController), playerController); inputComponent->AddObserver(manager); playerController->ObserveTimers(manager); manager->StartGame(); } glfwDestroyWindow(renderWindow); glfwTerminate(); }
PairsView::PairsView(BRect frame, const char* name, int width, int height, uint32 resizingMode) : BView(frame, name, resizingMode, B_WILL_DRAW), fWidth(width), fHeight(height), fNumOfCards(width * height), fRandPos(new int[fNumOfCards]), fPosX(new int[fNumOfCards]), fPosY(new int[fNumOfCards]) { CreateGameBoard(); _SetPairsBoard(); }
PairsView::PairsView(BRect frame, const char* name, uint8 rows, uint8 cols, uint8 iconSize) : BView(frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS), fRows(rows), fCols(cols), fIconSize(iconSize), fButtonsCount(rows * cols), fCardsCount(fButtonsCount / 2), fPairsButtonList(new BObjectList<PairsButton>(fButtonsCount)), fSmallBitmapsList(new BObjectList<BBitmap>(fCardsCount)), fMediumBitmapsList(new BObjectList<BBitmap>(fCardsCount)), fLargeBitmapsList(new BObjectList<BBitmap>(fCardsCount)), fRandomPosition(new int32[fButtonsCount]), fPositionX(new int32[fButtonsCount]), fPositionY(new int32[fButtonsCount]) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); CreateGameBoard(); _SetPairsBoard(); }