From 2335d6ebd30787d4ada6222c5b0ea4efb14eb6d3 Mon Sep 17 00:00:00 2001 From: AdmiralEmser Date: Mon, 15 Aug 2022 21:58:49 +0200 Subject: [PATCH] fix for old dev branch --- .gitignore | 2 +- FC-Chess/FC-Chess/CMakeLists.txt | 2 +- FC-Chess/FC-Chess/FC-Chess.cpp | 50 +++++++++++++++++++++++++------- FC-Chess/FC-Chess/FC-Chess.h | 42 +++++++++++++++++++++++---- FC-Chess/FC-Chess/graphics.cpp | 4 ++- FC-Chess/FC-Chess/graphics.h | 14 +++++++++ FC-Chess/FC-Chess/main.cpp | 17 +++++++++++ FC-Chess/to do.md | 12 ++++++++ README.md | 4 +-- 9 files changed, 127 insertions(+), 20 deletions(-) create mode 100644 FC-Chess/FC-Chess/graphics.h create mode 100644 FC-Chess/FC-Chess/main.cpp create mode 100644 FC-Chess/to do.md diff --git a/.gitignore b/.gitignore index 272c1e0..de367d6 100644 --- a/.gitignore +++ b/.gitignore @@ -351,4 +351,4 @@ MigrationBackup/ # own out/ -.vscode/ +.vscode/ \ No newline at end of file diff --git a/FC-Chess/FC-Chess/CMakeLists.txt b/FC-Chess/FC-Chess/CMakeLists.txt index d0de081..a6486b3 100644 --- a/FC-Chess/FC-Chess/CMakeLists.txt +++ b/FC-Chess/FC-Chess/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.8) # Add source to this project's executable. -add_executable (FC-Chess "FC-Chess.cpp" "FC-Chess.h") +add_executable (FC-Chess "main.cpp" "fc-chess.cpp" "graphics.cpp") if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET FC-Chess PROPERTY CXX_STANDARD 20) diff --git a/FC-Chess/FC-Chess/FC-Chess.cpp b/FC-Chess/FC-Chess/FC-Chess.cpp index 8c9f6b0..8c5cb6b 100644 --- a/FC-Chess/FC-Chess/FC-Chess.cpp +++ b/FC-Chess/FC-Chess/FC-Chess.cpp @@ -1,12 +1,42 @@ -// FC-Chess.cpp : Defines the entry point for the application. -// +#include "fc-chess.h" -#include "FC-Chess.h" - -using namespace std; - -int main() +void FCC::Chess::mainLoop() { - cout << "Hello CMake." << endl; - return 0; -} + FCC::ChessTUI tui; + + // preparing board: colors + for (int8_t i = 0; i < 8; i++) { + for (int j = 0; i < 2; i++) { + posColor[i][j] = (uint8_t)(PiecesColors::BLACK); + } + for (int j = 6; i < 8; i++) { + posColor[i][j] = (uint8_t)(PiecesColors::WHITE); + } + for (int j = 2; i < 7; i++) { + posColor[i][j] = (uint8_t)(PiecesColors::NONE); + } + } + // preparing board: pieces + for (int8_t i = 0; i < 8; i++) { + posPieces[1][i] = (uint8_t)(Pieces::PAWN); + posPieces[6][i] = (uint8_t)(Pieces::PAWN); + } + for (int8_t i = 0; i < 2; i++) { + posPieces[i][0] = (uint8_t)(Pieces::ROOK); + posPieces[i][7] = (uint8_t)(Pieces::ROOK); + posPieces[i][1] = (uint8_t)(Pieces::KNIGHT); + posPieces[i][6] = (uint8_t)(Pieces::KNIGHT); + posPieces[i][2] = (uint8_t)(Pieces::BISHOP); + posPieces[i][5] = (uint8_t)(Pieces::BISHOP); + posPieces[i][3] = (uint8_t)(Pieces::KING); + posPieces[i][4] = (uint8_t)(Pieces::QUEEN); + } + + // main loop + while(!gameEnded) { + + tui.mainLoop(); + } + + +} \ No newline at end of file diff --git a/FC-Chess/FC-Chess/FC-Chess.h b/FC-Chess/FC-Chess/FC-Chess.h index 6d4572e..e2452b8 100644 --- a/FC-Chess/FC-Chess/FC-Chess.h +++ b/FC-Chess/FC-Chess/FC-Chess.h @@ -1,8 +1,40 @@ -// FC-Chess.h : Include file for standard system include files, -// or project specific include files. - #pragma once - #include -// TODO: Reference additional headers your program requires here. +#include "graphics.h" + +namespace FCC +{ + // vars + enum class Pieces { + NONE, + PAWN, + ROOK, + BISHOP, + KNIGHT, + QUEEN, + KING + }; + enum class PiecesColors { + NONE, + BLACK = 10, + WHITE = 20 + }; + + // classes and funcs + class Chess + { + public: + // constructor and destructor + Chess() = default; + ~Chess() = default; + + // vars + uint8_t posPieces[8][8], posColor[8][8], posPossible[8][8]; + + // funcs + void mainLoop(); + private: + bool gameEnded; + }; +} diff --git a/FC-Chess/FC-Chess/graphics.cpp b/FC-Chess/FC-Chess/graphics.cpp index 004f3b6..9955f23 100644 --- a/FC-Chess/FC-Chess/graphics.cpp +++ b/FC-Chess/FC-Chess/graphics.cpp @@ -5,5 +5,7 @@ void FCC::ChessTUI::mainLoop() { } void FCC::ChessTUI::testLoop() { - std::cout << u8"\u2654"; + std::cout << "\u2654" << std::endl; + std::cout << "♔" << std::endl; + //std::cout << L"♔"; } \ No newline at end of file diff --git a/FC-Chess/FC-Chess/graphics.h b/FC-Chess/FC-Chess/graphics.h new file mode 100644 index 0000000..9a5b3da --- /dev/null +++ b/FC-Chess/FC-Chess/graphics.h @@ -0,0 +1,14 @@ +#pragma once +#include + +#include "FC-Chess.h" + +namespace FCC +{ + class ChessTUI + { + public: + void mainLoop(); + void testLoop(); + }; +} \ No newline at end of file diff --git a/FC-Chess/FC-Chess/main.cpp b/FC-Chess/FC-Chess/main.cpp new file mode 100644 index 0000000..b699344 --- /dev/null +++ b/FC-Chess/FC-Chess/main.cpp @@ -0,0 +1,17 @@ +// FC-Chess.cpp : Defines the entry point for the application. +// + +#include "fc-chess.h" + +//using namespace std; + +int main() +{ + FCC::Chess gm; + gm.mainLoop(); + + FCC::ChessTUI test; + test.testLoop(); + + return 0; +} diff --git a/FC-Chess/to do.md b/FC-Chess/to do.md new file mode 100644 index 0000000..428b440 --- /dev/null +++ b/FC-Chess/to do.md @@ -0,0 +1,12 @@ +# To Do List +## What features/functions do I need? +* save (autosave) +* load +* 2x 2D arrays: possible moves and positions +* check if move is allowed (vertical, etc.) +* check if another piece or rule blocks movement +* "special" rules +* switch between players +* check if position is out of boundaries +* TUI using ASCII +* \ No newline at end of file diff --git a/README.md b/README.md index 2b5520f..69a70b9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # FC-Chess ## Welcome -First of all I'd like to welcome you to FC Chess. I think I don't need to explain what it is, so I rather talk about my aims during this project. I want to achieve a more or less good looking GUI and cross-platform Chess game. In order to document my progress, I'll use the [wiki](https://github.com/AdmiralEmser/FC-Chess/wiki/Introduction-%5BHome%5D). There I will also write down some thoughts about my ideas including those that didn't make it into the project. +First of all I'd like to welcome you to FC Chess. I think I don't need to explain what it is, so I rather talk about my aims during this project. I want to achieve a more or less good looking GUI and cross-platform Chess game. In order to document my progress, I'll use the [wiki](https://github.com/AdmiralEmser/FC-Chess/wiki/Home). There I will also write down some thoughts about my ideas including those that didn't make it into the project. ## Contact You can reach me using E-Mail: admiralemser@gmail.com ## Warranty and Liablilty -This project is published under MIT license. For further information, check [the license file in this repo](https://github.com/AdmiralEmser/FC-Chess/blob/main/LICENSE) out. \ No newline at end of file +This project is published under MIT license. For further information, check [the license file in this repo](https://github.com/AdmiralEmser/FC-Chess/blob/main/LICENSE) out.