From 3b565e4d8cdcbba7b88377cd4ce0387da3bac682 Mon Sep 17 00:00:00 2001 From: AdmiralEmser Date: Sun, 9 Oct 2022 17:31:39 +0200 Subject: [PATCH] restructuring game startup --- FC-Chess/FC-Chess.cpp | 31 ++++++++++++++++++------------- FC-Chess/FC-Chess.h | 5 +++-- FC-Chess/main.cpp | 13 ++----------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/FC-Chess/FC-Chess.cpp b/FC-Chess/FC-Chess.cpp index 6c8988d..c0ca0d5 100644 --- a/FC-Chess/FC-Chess.cpp +++ b/FC-Chess/FC-Chess.cpp @@ -1,27 +1,35 @@ #include "FC-Chess.h" FCC::Chess::Chess() -{ - - //start game - FCC::Chess::startup(); - FCC::Chess::mainLoop(); -} - -void FCC::Chess::mainLoop() { // initialize user interface tui.startup(); + //start game + FCC::Chess::mainMenu(); +} + +void FCC::Chess::mainMenu() +{ + /* TO DO + - Add options + - call FCC::Chess::GameLoop when game begins */ +} + +void FCC::Chess::gameLoop() +{ + // initialize board + FCC::Chess::startupGame(); + // main loop while(!gameEnded) { - /*MISSING: user input*/ + /* To Do: user input */ tui.mainLoop(); } } -void FCC::Chess::startup() +void FCC::Chess::startupGame() { // preparing board: colors for (int8_t i = 0; i < 8; i++) { @@ -50,9 +58,6 @@ void FCC::Chess::startup() posPieces[i][3] = (uint8_t)(Pieces::KING); posPieces[i][4] = (uint8_t)(Pieces::QUEEN); } - - // set language to English (default) - // m_lang = FCC::Languages::ENGLISH; } bool FCC::Chess::checkIsEnemyOnField() diff --git a/FC-Chess/FC-Chess.h b/FC-Chess/FC-Chess.h index b48835a..8441648 100644 --- a/FC-Chess/FC-Chess.h +++ b/FC-Chess/FC-Chess.h @@ -50,8 +50,9 @@ namespace FCC uint8_t posPieces[8][8], posColor[8][8], posPossible[8][8], selX, selY, tarX, tarY; //tar = target, sel = selected, pos = possible // funcs - void startup(); - void mainLoop(); + void mainMenu(); + void startupGame(); + void gameLoop(); void checkHorizontalMovementAllowed(); void checkVerticalMovementAllowed(); void checkDiagonalMovementAllowed(); diff --git a/FC-Chess/main.cpp b/FC-Chess/main.cpp index c41f80f..f3d8dde 100644 --- a/FC-Chess/main.cpp +++ b/FC-Chess/main.cpp @@ -1,17 +1,8 @@ -// FC-Chess.cpp : Defines the entry point for the application. -// - -#include "FC-Chess.h" - -//using namespace std; +#include "FC-Chess.h" int main() { + // starting the game FCC::Chess gm; - - - // FCC::TUI test; - // test.testLoop(); - return 0; }