added: first text templates, first checks for piece movement,
Information: There is no tui.h since MSVC doesn't find the code in there... for some unexplainable reason... Check FC-Chess.h -> FCC::TUI for further information.
This commit is contained in:
@@ -352,3 +352,4 @@ MigrationBackup/
|
|||||||
# own
|
# own
|
||||||
out/
|
out/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
build/
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "windows-base",
|
|
||||||
"hidden": true,
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
|
||||||
"installDir": "${sourceDir}/out/install/${presetName}",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_C_COMPILER": "cl.exe",
|
|
||||||
"CMAKE_CXX_COMPILER": "cl.exe"
|
|
||||||
},
|
|
||||||
"condition": {
|
|
||||||
"type": "equals",
|
|
||||||
"lhs": "${hostSystemName}",
|
|
||||||
"rhs": "Windows"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "x64-debug",
|
|
||||||
"displayName": "x64 Debug",
|
|
||||||
"inherits": "windows-base",
|
|
||||||
"architecture": {
|
|
||||||
"value": "x64",
|
|
||||||
"strategy": "external"
|
|
||||||
},
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "x64-release",
|
|
||||||
"displayName": "x64 Release",
|
|
||||||
"inherits": "x64-debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "x86-debug",
|
|
||||||
"displayName": "x86 Debug",
|
|
||||||
"inherits": "windows-base",
|
|
||||||
"architecture": {
|
|
||||||
"value": "x86",
|
|
||||||
"strategy": "external"
|
|
||||||
},
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "x86-release",
|
|
||||||
"displayName": "x86 Release",
|
|
||||||
"inherits": "x86-debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "linux-debug",
|
|
||||||
"displayName": "Linux Debug",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
|
||||||
"installDir": "${sourceDir}/out/install/${presetName}",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
},
|
|
||||||
"condition": {
|
|
||||||
"type": "equals",
|
|
||||||
"lhs": "${hostSystemName}",
|
|
||||||
"rhs": "Linux"
|
|
||||||
},
|
|
||||||
"vendor": {
|
|
||||||
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
|
|
||||||
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "macos-debug",
|
|
||||||
"displayName": "macOS Debug",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
|
||||||
"installDir": "${sourceDir}/out/install/${presetName}",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
},
|
|
||||||
"condition": {
|
|
||||||
"type": "equals",
|
|
||||||
"lhs": "${hostSystemName}",
|
|
||||||
"rhs": "Darwin"
|
|
||||||
},
|
|
||||||
"vendor": {
|
|
||||||
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
|
|
||||||
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
cmake_minimum_required (VERSION 3.8)
|
cmake_minimum_required (VERSION 3.8)
|
||||||
|
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_executable (FC-Chess "main.cpp" "fc-chess.cpp" "graphics.cpp")
|
add_executable (FC-Chess "main.cpp" "FC-Chess.cpp" "tui.cpp")
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
set_property(TARGET FC-Chess PROPERTY CXX_STANDARD 20)
|
set_property(TARGET FC-Chess PROPERTY CXX_STANDARD 20)
|
||||||
|
|||||||
+56
-7
@@ -1,9 +1,29 @@
|
|||||||
#include "fc-chess.h"
|
#include "FC-Chess.h"
|
||||||
|
|
||||||
|
FCC::Chess::Chess()
|
||||||
|
{
|
||||||
|
|
||||||
|
//start game
|
||||||
|
FCC::Chess::startup();
|
||||||
|
FCC::Chess::mainLoop();
|
||||||
|
}
|
||||||
|
|
||||||
void FCC::Chess::mainLoop()
|
void FCC::Chess::mainLoop()
|
||||||
{
|
{
|
||||||
FCC::ChessTUI tui;
|
// initialize user interface
|
||||||
|
|
||||||
|
// tui.startup();
|
||||||
|
|
||||||
|
// main loop
|
||||||
|
while(!gameEnded)
|
||||||
|
{
|
||||||
|
/*MISSING: user input*/
|
||||||
|
// tui.mainLoop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCC::Chess::startup()
|
||||||
|
{
|
||||||
// preparing board: colors
|
// preparing board: colors
|
||||||
for (int8_t i = 0; i < 8; i++) {
|
for (int8_t i = 0; i < 8; i++) {
|
||||||
for (int j = 0; i < 2; i++) {
|
for (int j = 0; i < 2; i++) {
|
||||||
@@ -32,11 +52,40 @@ void FCC::Chess::mainLoop()
|
|||||||
posPieces[i][4] = (uint8_t)(Pieces::QUEEN);
|
posPieces[i][4] = (uint8_t)(Pieces::QUEEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// main loop
|
// set language to English (default)
|
||||||
while(!gameEnded) {
|
// m_lang = FCC::Languages::ENGLISH;
|
||||||
|
|
||||||
tui.mainLoop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FCC::Chess::checkIsEnemyOnField()
|
||||||
|
{
|
||||||
|
// Check if the selected piece/field unequals the target piece/field => is true then
|
||||||
|
if (posColor[selX][selY] != posColor[tarX][tarY])
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FCC::Chess::checkSelectedPosInBounds()
|
||||||
|
{
|
||||||
|
// check if X and Y values are below 8. No negative values have to be checked since the var type is unsigned int
|
||||||
|
if (selX <= 7 && selX <= 7)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FCC::Chess::checkTargetPosInBounds()
|
||||||
|
{
|
||||||
|
// check if X and Y values are below 8. No negative values have to be checked since the var type is unsigned int
|
||||||
|
if (tarX <= 7 && tarX <= 7)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//void FCC::Chess::set_lang(FCC::Languages lang) {
|
||||||
|
// m_lang = lang;
|
||||||
|
//}
|
||||||
|
|||||||
+43
-6
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <iostream>
|
//#include <iostream>
|
||||||
|
// #include "tui.h"
|
||||||
#include "graphics.h"
|
#include "lang.h"
|
||||||
|
|
||||||
namespace FCC
|
namespace FCC
|
||||||
{
|
{
|
||||||
@@ -22,19 +22,56 @@ namespace FCC
|
|||||||
};
|
};
|
||||||
|
|
||||||
// classes and funcs
|
// classes and funcs
|
||||||
|
class TUI
|
||||||
|
{
|
||||||
|
/* Why is FCC::TUI here and not in tui.h, so another file? Well, that's quite easy. MSVC doesn't know how to access code from other files, apparently.
|
||||||
|
Error code is that class FCC::TUI wouldn't be a member of namespace FCC - which is a wrong statement. It is a member of FCC.
|
||||||
|
So yeah, thanks Microsoft.*/
|
||||||
|
|
||||||
|
public:
|
||||||
|
// constructor and destructor
|
||||||
|
TUI() = default;
|
||||||
|
virtual ~TUI() = default;
|
||||||
|
|
||||||
|
// funcs
|
||||||
|
void startup();
|
||||||
|
void mainLoop();
|
||||||
|
void testLoop();
|
||||||
|
};
|
||||||
|
|
||||||
class Chess
|
class Chess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// constructor and destructor
|
// constructor and destructor
|
||||||
Chess() = default;
|
Chess();
|
||||||
~Chess() = default;
|
virtual ~Chess() = default;
|
||||||
|
|
||||||
// vars
|
// vars
|
||||||
uint8_t posPieces[8][8], posColor[8][8], posPossible[8][8];
|
uint8_t posPieces[8][8], posColor[8][8], posPossible[8][8], selX, selY, tarX, tarY; //tar = target, sel = selected, pos = possible
|
||||||
|
|
||||||
// funcs
|
// funcs
|
||||||
|
void startup();
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
|
void checkHorizontalMovementAllowed();
|
||||||
|
void checkVerticalMovementAllowed();
|
||||||
|
void checkDiagonalMovementAllowed();
|
||||||
|
//void set_lang(FCC::Languages lang);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// vars
|
||||||
bool gameEnded;
|
bool gameEnded;
|
||||||
|
|
||||||
|
// texts for tui and gui
|
||||||
|
FCC::Lang lang;
|
||||||
|
FCC::TUI tui;
|
||||||
|
//FCC::ChessLang chessLangObj;
|
||||||
|
//FCC::Languages m_lang{ FCC::Languages::ENGLISH };
|
||||||
|
|
||||||
|
// funcs
|
||||||
|
void input();
|
||||||
|
bool checkIsEnemyOnField();
|
||||||
|
bool checkSelectedPosInBounds();
|
||||||
|
bool checkTargetPosInBounds();
|
||||||
|
void resetFieldColors();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "FC-Chess.h"
|
||||||
|
|
||||||
|
namespace FCC
|
||||||
|
{
|
||||||
|
class TUI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructor and destructor
|
||||||
|
TUI() = default;
|
||||||
|
virtual ~TUI() = default;
|
||||||
|
|
||||||
|
// funcs
|
||||||
|
void startup();
|
||||||
|
void mainLoop();
|
||||||
|
void testLoop();
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,10 +1,18 @@
|
|||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
// #include "FC-Chess.h"
|
||||||
|
|
||||||
void FCC::ChessTUI::mainLoop() {
|
void FCC::TUI::startup()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FCC::ChessTUI::testLoop() {
|
void FCC::TUI::mainLoop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCC::TUI::testLoop()
|
||||||
|
{
|
||||||
std::cout << "\u2654" << std::endl;
|
std::cout << "\u2654" << std::endl;
|
||||||
std::cout << "♔" << std::endl;
|
std::cout << "♔" << std::endl;
|
||||||
//std::cout << L"♔";
|
//std::cout << L"♔";
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "FC-Chess.h"
|
||||||
|
|
||||||
|
namespace FCC
|
||||||
|
{
|
||||||
|
class TUI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructor and destructor
|
||||||
|
TUI() = default;
|
||||||
|
virtual ~TUI() = default;
|
||||||
|
|
||||||
|
// funcs
|
||||||
|
void startup();
|
||||||
|
void mainLoop();
|
||||||
|
void testLoop();
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "lang.h"
|
||||||
|
|
||||||
|
void FCC::ChessLang::setLanguage(uint8_t setLangTo)
|
||||||
|
{
|
||||||
|
language = setLangTo;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
//#include "FC-Chess.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace FCC {
|
||||||
|
enum class Languages {
|
||||||
|
ENGLISH,
|
||||||
|
GERMAN
|
||||||
|
};
|
||||||
|
}
|
||||||
|
namespace FCC::ChessLang
|
||||||
|
{
|
||||||
|
inline std::string testString(FCC::Languages lang) {
|
||||||
|
switch (lang) {
|
||||||
|
case FCC::Languages::ENGLISH:
|
||||||
|
return "Hello World";
|
||||||
|
case FCC::Languages::GERMAN:
|
||||||
|
return "Hallo Welt";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "FC-Chess.h"
|
||||||
|
|
||||||
|
namespace FCC
|
||||||
|
{
|
||||||
|
class TUI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructor and destructor
|
||||||
|
TUI() = default;
|
||||||
|
virtual ~TUI() = default;
|
||||||
|
|
||||||
|
// funcs
|
||||||
|
void startup();
|
||||||
|
void mainLoop();
|
||||||
|
void testLoop();
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "FC-Chess.h"
|
|
||||||
|
|
||||||
namespace FCC
|
|
||||||
{
|
|
||||||
class ChessTUI
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void mainLoop();
|
|
||||||
void testLoop();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace FCC
|
||||||
|
{
|
||||||
|
class Lang
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// texts shown in gui/tui
|
||||||
|
std::string menuButtonPlay = "Start Game!";
|
||||||
|
std::string menuButtonSettings = "Settings";
|
||||||
|
std::string menuButtonCredits = "Credits";
|
||||||
|
std::string menuButtonExitGame = "Exit to Desktop";
|
||||||
|
std::string error = "An error occoured. The game will exit now.";
|
||||||
|
std::string gameForbiddenMove = "This move is not allowed.";
|
||||||
|
std::string credits = "FoxCreation Chess by SinusFox 2022.\nContact: admiralemser@gmail.com\nhttps://github.com/AdmiralEmser/FC-Chess";
|
||||||
|
std::string backButton = "Back <--";
|
||||||
|
};
|
||||||
|
}
|
||||||
+4
-4
@@ -1,17 +1,17 @@
|
|||||||
// FC-Chess.cpp : Defines the entry point for the application.
|
// FC-Chess.cpp : Defines the entry point for the application.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "fc-chess.h"
|
#include "FC-Chess.h"
|
||||||
|
|
||||||
//using namespace std;
|
//using namespace std;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
FCC::Chess gm;
|
FCC::Chess gm;
|
||||||
gm.mainLoop();
|
|
||||||
|
|
||||||
FCC::ChessTUI test;
|
|
||||||
test.testLoop();
|
// FCC::TUI test;
|
||||||
|
// test.testLoop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// #include "tui.h"
|
||||||
|
#include "FC-Chess.h"
|
||||||
|
|
||||||
|
void FCC::TUI::startup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCC::TUI::mainLoop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCC::TUI::testLoop()
|
||||||
|
{
|
||||||
|
std::cout << "\u2654" << std::endl;
|
||||||
|
std::cout << "♔" << std::endl;
|
||||||
|
//std::cout << L"♔";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user