diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa40bd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.vs/* +/vc/* diff --git a/BoardGame.sln b/BoardGame.sln deleted file mode 100644 index bcb90e0..0000000 --- a/BoardGame.sln +++ /dev/null @@ -1,30 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.36203.30 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BoardGame", "BoardGame\BoardGame.vcxproj", "{19A76AF3-0481-4CCC-B842-42AE45CA36FF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Debug|x64.ActiveCfg = Debug|x64 - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Debug|x86.ActiveCfg = Debug|Win32 - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Debug|x86.Build.0 = Debug|Win32 - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Release|x64.ActiveCfg = Release|x64 - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Release|x64.Build.0 = Release|x64 - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Release|x86.ActiveCfg = Release|Win32 - {19A76AF3-0481-4CCC-B842-42AE45CA36FF}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {24FAB3E0-8459-4EB5-8375-4B52435D172E} - EndGlobalSection -EndGlobal diff --git a/BoardGame/Board.cpp b/BoardGame/Board.cpp deleted file mode 100644 index 27fe01b..0000000 --- a/BoardGame/Board.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "Board.h" -#include "Snake.h" -#include "Fruit.h" - -int Board::m_BoardSize = 16; -std::random_device rd; -std::mt19937 gen(rd()); - -Board::Board() -{ - for (int x = 0; x < m_BoardSize; x++) - { - for (int y = 0; y < m_BoardSize; y++) - { - int current = x * 16 + y; - - if (current == (m_BoardSize * m_BoardSize) / 2) - { - m_Board.push_back(std::make_shared(5.0f, 1, 150)); - } - else - { - m_Board.push_back(std::make_shared(y, x)); - } - } - } -} - -void Board::renderBoard() -{ - int TotalSize = m_BoardSize * m_BoardSize; - system("cls"); //clear le terminal à chaque nouveau render - - for (int i = 0; i < TotalSize; i++) - { - m_Board[i]->render(); - - if ((i + 1) % m_BoardSize == 0) - { - std::cout << std::endl; - } - } -} - - -std::shared_ptr Board::getSnake() const -{ - for (auto& entity : m_Board) - { - - std::shared_ptr snake = std::dynamic_pointer_cast(entity); - if (snake != nullptr) - { - return snake; - } - } - return nullptr; -} - -void Board::moveSnake(int direction) -{ - std::shared_ptr snake = getSnake(); - if (!snake) return; - - int oldHeadPosition = snake->getPosition(); - - std::vector oldBody = snake->getBody(); - - snake->move(direction); - - int newHeadPosition = snake->getPosition(); - - if (std::dynamic_pointer_cast(m_Board[newHeadPosition])) - { - auto fruit = spawnFruit(); - snake->addSegment(1); - snake->addScore(fruit->getPoints()); - } - - for (int pos : oldBody) - { - int oldY = pos / m_BoardSize; - int oldX = pos % m_BoardSize; - m_Board[pos] = std::make_shared(oldX, oldY); - } - - for (int pos : snake->getBody()) - { - m_Board[pos] = snake; - } - - InvalidateRect(hwnd, NULL, TRUE); -} - - -std::shared_ptr Board::spawnFruit() -{ - std::vector emptyPositions; - for (int i = 0; i < m_Board.size(); i++) - { - if (std::dynamic_pointer_cast(m_Board[i])) - { - emptyPositions.push_back(i); - } - } - - if (emptyPositions.empty()) return nullptr; - - std::uniform_int_distribution<> distrib(0, emptyPositions.size() - 1); - - int chosenIndex = emptyPositions[distrib(gen)]; - - m_Board[chosenIndex] = std::make_shared(chosenIndex); - return std::dynamic_pointer_cast(m_Board[chosenIndex]); -} -int Board::getSnakeSegmentOrder(int index) const { - auto snake = getSnake(); - - const auto& body = snake->getBody(); - - for (size_t i = 0; i < body.size(); ++i) { - if (body[i] == index) - return static_cast(i); - } - return -1; -} diff --git a/BoardGame/Board.h b/BoardGame/Board.h deleted file mode 100644 index 8bfa10d..0000000 --- a/BoardGame/Board.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "Point.h" -#include "stdafx.h" -#include "Snake.h" -#include "fruit.h" - -class Board -{ - -public: - Board(); - void renderBoard(); - static int getBoardSize() { return m_BoardSize; }; - static void setBoardSize(int Size) { m_BoardSize = Size; } - std::shared_ptr getSnake() const; - void moveSnake(int direction); - const std::vector>& getEntities() const { return m_Board; } - void setWindowHandle(HWND hwnd) { this->hwnd = hwnd; }; - std::shared_ptr spawnFruit(); - std::shared_ptr getEntityAt(int index) const - { - return m_Board[index]; - } - int getSnakeSegmentOrder(int index) const; - - -private: - std::vector>m_Board; - static int m_BoardSize; - HWND hwnd = nullptr; - -}; - - diff --git a/BoardGame/BoardGame.vcxproj.filters b/BoardGame/BoardGame.vcxproj.filters deleted file mode 100644 index 32a4aa1..0000000 --- a/BoardGame/BoardGame.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - Fichiers sources - - - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - Fichiers d%27en-tête - - - \ No newline at end of file diff --git a/BoardGame/BoardGame.vcxproj.user b/BoardGame/BoardGame.vcxproj.user deleted file mode 100644 index 88a5509..0000000 --- a/BoardGame/BoardGame.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/BoardGame/Entity.cpp b/BoardGame/Entity.cpp deleted file mode 100644 index b0ae70b..0000000 --- a/BoardGame/Entity.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "Entity.h" - diff --git a/BoardGame/Entity.h b/BoardGame/Entity.h deleted file mode 100644 index 2c46e0a..0000000 --- a/BoardGame/Entity.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "stdafx.h" - -class Entity -{ -public: - virtual ~Entity() = default; - virtual void render() const = 0; - - int getPosition() const { return Position; } - void setPosition(int pos) { Position = pos; } - virtual bool isCollidable() { return false; }; - -protected: - int Position; -}; diff --git a/BoardGame/Fenetre.cpp b/BoardGame/Fenetre.cpp deleted file mode 100644 index 8fe1321..0000000 --- a/BoardGame/Fenetre.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "Fenetre.h" -#include -#define TIMER_ID 1 - - -using namespace std::chrono; -namespace Fenetre { - - int frames = 0; - int fps = 0; - auto lastTime = steady_clock::now(); - - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { - - switch (uMsg) - { - case WM_DESTROY: - KillTimer(hwnd, TIMER_ID); - PostQuitMessage(0); - return 0; - - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); - - Board* board = (Board*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (board) - { - WNDRenderBoard(hwnd, hdc, *board); - frames++; - - auto currentTime = steady_clock::now(); - auto elapsed = duration_cast(currentTime - lastTime).count(); - - if (elapsed >= 1) { - fps = frames; - frames = 0; - lastTime = currentTime; - - - std::cout << "FPS: " << fps << std::endl; - std::wstring fpsText = L"FPS: " + std::to_wstring(fps); - std::wstring title = L"Snake - FPS: " + std::to_wstring(fps); - SetWindowText(hwnd, title.c_str()); - TextOut(hdc, 10, 10, fpsText.c_str(), fpsText.length()); - } - } - //HBRUSH CustomBrush = CreateSolidBrush(50);//def de la couleur du pinceau - //FillRect(hdc, &ps.rcPaint, CustomBrush);//application de la peinture sur le background - //DeleteObject(CustomBrush);//nettoyage du pinceau - - EndPaint(hwnd, &ps); - } - break; - case WM_CREATE: - { - LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam; - Board* board = (Board*)pcs->lpCreateParams; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)board); - auto speed = board->getSnake()->getSpeed(); - SetTimer(hwnd, TIMER_ID, 50-speed, NULL); - - } - break; - case WM_KEYDOWN: - { - Board* board = (Board*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - auto snake = board->getSnake(); - - int desiredDirection = snake->getCurrentDirection(); - - switch (wParam) - { - case 'Q': desiredDirection = 1; break; - case 'Z': desiredDirection = 2; break; - case 'D': desiredDirection = 3; break; - case 'S': desiredDirection = 4; break; - } - - if (!snake->isOpposite(snake->getNextDirection(), desiredDirection)) - { - snake->setNextDirection(desiredDirection); - } - } - break; - - case WM_TIMER: - { - Board* board = (Board*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (board) - { - auto snake = board->getSnake(); - if (snake->getAlive()) - { - board->moveSnake(snake->getNextDirection()); - - snake->setCurrentDirection(snake->getNextDirection()); - - InvalidateRect(hwnd, NULL, TRUE); - } - else - { - KillTimer(hwnd, TIMER_ID); - } - } - } - break; - - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); - } - - HWND CreateMainWindow(Board *board) - { - const wchar_t CLASS_NAME[] = L"SnakeWindow"; - - WNDCLASS wc = {}; - wc.lpfnWndProc = Fenetre::WindowProc; - wc.hInstance = GetModuleHandle(NULL); - wc.lpszClassName = CLASS_NAME; - - RegisterClass(&wc); - - HWND hwnd = CreateWindowEx( - 0, CLASS_NAME, L"Snake", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, GetModuleHandle(NULL), board - ); - - if (hwnd == NULL) { - std::cout << "debug: echec de creation de la fenetre\n"; - exit(1); - } - - ShowWindow(hwnd, SW_SHOW); - return hwnd; - } - - void Fenetre::WNDRenderBoard(HWND hwnd, HDC hdc, const Board& board) - { - RECT clientRect; - GetClientRect(hwnd, &clientRect); - - int squareWidth = clientRect.right / Board::getBoardSize(); - int squareHeight = clientRect.bottom / Board::getBoardSize(); - - for (int row = 0; row < Board::getBoardSize(); ++row) - { - for (int col = 0; col < Board::getBoardSize(); ++col) - { - RECT square = { - col * squareWidth, - row * squareHeight, - (col + 1) * squareWidth, - (row + 1) * squareHeight - }; - - int index = row * Board::getBoardSize() + col; - std::shared_ptr entity = board.getEntityAt(index); - - - HBRUSH brush = nullptr; - auto snakeLength = board.getSnake()->getBody().size(); - if (std::dynamic_pointer_cast(entity)) - { - int segmentOrder = board.getSnakeSegmentOrder(index); - int snakeLength = board.getSnake()->getBody().size(); - - if (segmentOrder != -1 && snakeLength > 1) - { - float ratio = static_cast(segmentOrder) / (snakeLength - 1); - - int brightness = static_cast(ratio * 200); - - int red = brightness; - int green = brightness; - int blue = 255; - - brush = CreateSolidBrush(RGB(red, green, blue)); - } - else - { - brush = CreateSolidBrush(RGB(0, 0, 255)); //bleu si ça bug - } - } - else if (std::dynamic_pointer_cast(entity)) - { - brush = CreateSolidBrush(RGB(255, 0, 0)); - } - else - { - brush = CreateSolidBrush(RGB(0, 255, 0)); - } - - FillRect(hdc, &square, brush); - DeleteObject(brush); - SetBkMode(hdc, TRANSPARENT); - - - int segmentOrder = board.getSnakeSegmentOrder(index); - if (segmentOrder != -1) { - std::wstring text = std::to_wstring(segmentOrder); - DrawText(hdc, text.c_str(), -1, &square, DT_CENTER | DT_VCENTER | DT_SINGLELINE); - } - - - } - } - } - - } - - diff --git a/BoardGame/Fenetre.h b/BoardGame/Fenetre.h deleted file mode 100644 index e7c767f..0000000 --- a/BoardGame/Fenetre.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "stdafx.h" -#include "board.h" - -#include "Fruit.h" -namespace Fenetre { - - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - HWND CreateMainWindow(Board* board); - void WNDRenderBoard(HWND hwnd, HDC hdc, const Board& board); -} diff --git a/BoardGame/Fruit.h b/BoardGame/Fruit.h deleted file mode 100644 index b212db0..0000000 --- a/BoardGame/Fruit.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Entity.h" -#include "stdafx.h" - - - - -class Fruit : public Entity -{ -public: - Fruit(int pos) { this->Position = pos; } - bool isCollidable() override { return true; }; - void render() const override { - std::cout << "%"; - } - int getPoints() { return points; }; - -private: - int points = 1000; - -}; diff --git a/BoardGame/GodHelpMe.cpp b/BoardGame/GodHelpMe.cpp deleted file mode 100644 index bd427bd..0000000 --- a/BoardGame/GodHelpMe.cpp +++ /dev/null @@ -1,547 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Board; - -class Entity -{ -public: - virtual ~Entity() = default; - virtual void render() const = 0; - - int getPosition() const { return Position; } - void setPosition(int pos) { Position = pos; } - virtual bool isCollidable() { return false; }; - -protected: - int Position; -}; - -class Snake : public Entity -{ -public: - Snake(float speed, int score, int startPosition) - : m_Speed(speed), m_Score(score) - { - m_Body.push_back(startPosition); - Position = startPosition; - } - void addSegment(int count) - { - for (int i = 0; i < count; ++i) - { - m_Body.push_back(m_Body.back()); //rajout d'un segment dans la derniere position - } - } - - - void addSpeed(float speed); - - void removeSpeed(float speed); - - void move(int direction); - - void render() const override { - //system("color 0C"); - std::cout << "\033[34m~\033[0m"; //ANSI code color pour changement de la couleur dans terminal - } - - void setPosition(int pos) { position = pos; }; - - int getPosition() const { return m_Body[0]; } - - bool isCollidable() override { return true; }; - - void addScore(int score) { this->m_Score += score; }; - - int getScore() { return m_Score; }; - std::vector getBody() { return m_Body; }; - int wrap(int value, int max); - - -private: - - float m_Speed = 5.0f; - int m_Length = 1; - int position; - const int _OFFSET = 16; - int m_Score = 0; - int m_currentDirection = 1; - - - std::vector m_Body;//liste des segments du serpent - friend std::ostream& operator<<(std::ostream& os, const Snake& snake); - - - -}; - -class Fruit : public Entity -{ -public: - Fruit(int pos) { this->Position = pos; } - bool isCollidable() override { return true; }; - void render() const override { - std::cout << "%"; - } - int getPoints() { return points; }; - -private: - int points = 1000; - -}; -namespace Fenetre { - - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - HWND CreateMainWindow(Board* board); - void WNDRenderBoard(HWND hwnd, HDC hdc, const Board& board); -} - - -class Board -{ - -public: - Board(); - void renderBoard(); - static int getBoardSize() { return m_BoardSize; }; - static void setBoardSize(int Size) { m_BoardSize = Size; } - std::shared_ptr getSnake() const; - void moveSnake(int direction); - const std::vector>& getEntities() const { return m_Board; } - - void setWindowHandle(HWND hwnd) { this->hwnd = hwnd; }; - std::shared_ptr spawnFruit(); - std::shared_ptr getEntityAt(int index) const - { - return m_Board[index]; - } - int getSnakeSegmentOrder(int index) const; - - -private: - std::vector>m_Board; - static int m_BoardSize; - HWND hwnd = nullptr; - -}; - -class Point : public Entity -{ -public: - Point(int x, int y); - - int getPosX() { return x; }; - int getPosY() { return y; }; - bool isCollidable() override { return false; }; - void render() const override { - //system("color 0A"); - std::cout << "\033[32mo\033[0m"; - } - -private: - int x, y; - int Position = 0; - - friend std::ostream& operator<<(std::ostream& os, const Point& point); -}; - -void Snake::addSpeed(float speed) -{ - m_Speed += speed; -} -void Snake::removeSpeed(float speed) -{ - m_Speed -= speed; -} -int Snake::wrap(int value, int max) { - return (value + max) % max; -} - -void Snake::move(int direction) -{ - //gros pavé pour check si le joueur fait demi tour direct* - //[TODO] rendre lisible et optimisé - if ((m_currentDirection == 1 && direction == 3) || - (m_currentDirection == 3 && direction == 1) || - (m_currentDirection == 2 && direction == 4) || - (m_currentDirection == 4 && direction == 2)) - { - direction = m_currentDirection; // on ignore si le joueur fait un 180° - } - else - { - m_currentDirection = direction; - int head = m_Body.front(); - int row = head / 16; - int col = head % 16; - - switch (direction) - { - case 1: col--; break; - case 2: row--; break; - case 3: col++; break; - case 4: row++; break; - } - - row = wrap(row, 16); - col = wrap(col, 16); - - int newHead = row * 16 + col; - - // check la collision on skip la tete sinon probleme - for (size_t i = 1; i < m_Body.size(); ++i) - { - if (newHead == m_Body[i]) - { - std::cout << "Parti fini" << "\n"; - exit(0); // on quitte pour l'instant - //[TODO] faire un menu et un écran de fin - } - } - - for (int i = m_Body.size() - 1; i > 0; --i) - { - m_Body[i] = m_Body[i - 1]; - } - - m_Body[0] = newHead; - Position = newHead; - } - - -} - - - -std::ostream& operator<<(std::ostream& os, const Snake& snake) -{ - os << "~"; - return os; -} -Point::Point(int x, int y) -{ - this->x = x; - this->y = y; - this->Position = y * 16 + x; -} -std::ostream& operator<<(std::ostream& os, const Point& point) -{ - //os << "Point(x: " << point.x << ", y: " << point.y << ", place: " << point.place << ")"; - os << 'o'; - return os; -} - -namespace Fenetre { - - - - - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { - - switch (uMsg) - { - case WM_DESTROY: - PostQuitMessage(0); - return 0; - - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); - - Board* board = (Board*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (board) - { - WNDRenderBoard(hwnd, hdc, *board); - } - //HBRUSH CustomBrush = CreateSolidBrush(50);//def de la couleur du pinceau - //FillRect(hdc, &ps.rcPaint, CustomBrush);//application de la peinture sur le background - //DeleteObject(CustomBrush);//nettoyage du pinceau - - EndPaint(hwnd, &ps); - } - break; - case WM_CREATE: - { - LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam; - Board* board = (Board*)pcs->lpCreateParams; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)board); - } - break; - - case WM_KEYDOWN: - { - Board* board = (Board*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (board) - { - switch (wParam) - { - case 'Q': board->moveSnake(1); break; - case 'Z': board->moveSnake(2); break; - case 'D': board->moveSnake(3); break; - case 'S': board->moveSnake(4); break; - } - } - } - break; - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); - } - - HWND CreateMainWindow(Board* board) - { - const wchar_t CLASS_NAME[] = L"SnakeWindow"; - - WNDCLASS wc = {}; - wc.lpfnWndProc = Fenetre::WindowProc; - wc.hInstance = GetModuleHandle(NULL); - wc.lpszClassName = CLASS_NAME; - - RegisterClass(&wc); - - HWND hwnd = CreateWindowEx( - 0, CLASS_NAME, L"Snake", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, GetModuleHandle(NULL), board - ); - - if (hwnd == NULL) { - std::cout << "debug: echec de creation de la fenetre\n"; - exit(1); - } - - ShowWindow(hwnd, SW_SHOW); - return hwnd; - } - - void Fenetre::WNDRenderBoard(HWND hwnd, HDC hdc, const Board& board) - { - RECT clientRect; - GetClientRect(hwnd, &clientRect); - - int squareWidth = clientRect.right / Board::getBoardSize(); - int squareHeight = clientRect.bottom / Board::getBoardSize(); - - for (int row = 0; row < Board::getBoardSize(); ++row) - { - for (int col = 0; col < Board::getBoardSize(); ++col) - { - RECT square = { - col * squareWidth, - row * squareHeight, - (col + 1) * squareWidth, - (row + 1) * squareHeight - }; - - int index = row * Board::getBoardSize() + col; - std::shared_ptr entity = board.getEntityAt(index); - - - HBRUSH brush = nullptr; - - if (std::dynamic_pointer_cast(entity)) - { - brush = CreateSolidBrush(RGB(0, 0, 255)); - - } - else if (std::dynamic_pointer_cast(entity)) - { - brush = CreateSolidBrush(RGB(255, 0, 0)); - } - else - { - brush = CreateSolidBrush(RGB(0, 255, 0)); - } - - FillRect(hdc, &square, brush); - DeleteObject(brush); - SetBkMode(hdc, TRANSPARENT); - - - int segmentOrder = board.getSnakeSegmentOrder(index); - if (segmentOrder != -1) { - std::wstring text = std::to_wstring(segmentOrder); - DrawText(hdc, text.c_str(), -1, &square, DT_CENTER | DT_VCENTER | DT_SINGLELINE); - } - - - } - } - } - -}int Board::m_BoardSize = 16; - - -Board::Board() -{ - for (int x = 0; x < m_BoardSize; x++) - { - for (int y = 0; y < m_BoardSize; y++) - { - int current = x * 16 + y; - - if (current == (m_BoardSize * m_BoardSize) / 2) - { - m_Board.push_back(std::make_shared(5.0f, 1, 128)); - } - else - { - m_Board.push_back(std::make_shared(y, x)); - } - } - } -} - -void Board::renderBoard() -{ - int TotalSize = m_BoardSize * m_BoardSize; - system("cls"); //clear le terminal à chaque nouveau render - - for (int i = 0; i < TotalSize; i++) - { - m_Board[i]->render(); - - if ((i + 1) % m_BoardSize == 0) - { - std::cout << std::endl; - } - } -} - - -std::shared_ptr Board::getSnake() const -{ - for (auto& entity : m_Board) - { - - std::shared_ptr snake = std::dynamic_pointer_cast(entity); - if (snake != nullptr) - { - return snake; - } - } - return nullptr; -} - -void Board::moveSnake(int direction) -{ - std::shared_ptr snake = getSnake(); - if (!snake) return; - - int oldHeadPosition = snake->getPosition(); - - std::vector oldBody = snake->getBody(); - - snake->move(direction); - - int newHeadPosition = snake->getPosition(); - - if (std::dynamic_pointer_cast(m_Board[newHeadPosition])) - { - auto fruit = spawnFruit(); - snake->addSegment(1); - snake->addScore(fruit->getPoints()); - } - - for (int pos : oldBody) - { - int oldY = pos / m_BoardSize; - int oldX = pos % m_BoardSize; - m_Board[pos] = std::make_shared(oldX, oldY); - } - - for (int pos : snake->getBody()) - { - m_Board[pos] = snake; - } - - InvalidateRect(hwnd, NULL, TRUE); -} - - -std::shared_ptr Board::spawnFruit() -{ - std::vector emptyPositions; - for (int i = 0; i < m_Board.size(); i++) - { - if (std::dynamic_pointer_cast(m_Board[i])) - { - emptyPositions.push_back(i); - } - } - - if (emptyPositions.empty()) return nullptr; - - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<> distrib(0, emptyPositions.size() - 1); - - int chosenIndex = emptyPositions[distrib(gen)]; - - m_Board[chosenIndex] = std::make_shared(chosenIndex); - return std::dynamic_pointer_cast(m_Board[chosenIndex]); -} -int Board::getSnakeSegmentOrder(int index) const { - auto snake = getSnake(); - - const auto& body = snake->getBody(); - - for (size_t i = 0; i < body.size(); ++i) { - if (body[i] == index) - return static_cast(i); - } - return -1; -} - - -int main() { - - Board board; - - HWND hwnd = Fenetre::CreateMainWindow(&board); - board.setWindowHandle(hwnd); - - std::shared_ptr snake = board.getSnake(); - if (!snake) - { - std::cout << "debug: snake pas trouvé\n\r"; - return 1; - } - - board.spawnFruit(); - - char input = ' '; - MSG msg = { }; - - while (input != 'x') - { - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) - { - input = 'x'; - break; - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - board.renderBoard(); - - std::cout << "\ndeplace toi avec zqsd\n"; - std::cout << "Ton Score:" << snake->getScore(); - } - - std::cout << "partie fini" << std::endl; - return 0; -} diff --git a/BoardGame/Main.cpp b/BoardGame/Main.cpp deleted file mode 100644 index a413512..0000000 --- a/BoardGame/Main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "Board.h" -#include "stdafx.h" -#include -#include "Fenetre.h" - - -int main() { - - Board board; - - HWND hwnd = Fenetre::CreateMainWindow(&board); - board.setWindowHandle(hwnd); - - std::shared_ptr snake = board.getSnake(); - if (!snake) - { - std::cout << "debug: snake pas trouvé\n\r"; - return 1; - } - - board.spawnFruit(); - - char input = ' '; - - MSG msg = {}; - while (GetMessage(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - - std::cout << "partie fini" << std::endl; - return 0; -} diff --git a/BoardGame/Point.cpp b/BoardGame/Point.cpp deleted file mode 100644 index b635728..0000000 --- a/BoardGame/Point.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "Point.h" - - -Point::Point(int x, int y) -{ - this->x = x; - this->y = y; - this->Position = y * 16 + x; -} -std::ostream& operator<<(std::ostream& os, const Point& point) -{ - //os << "Point(x: " << point.x << ", y: " << point.y << ", place: " << point.place << ")"; - os << 'o'; - return os; -} - - diff --git a/BoardGame/Point.h b/BoardGame/Point.h deleted file mode 100644 index d3b13a2..0000000 --- a/BoardGame/Point.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "stdafx.h" -#include "Entity.h" -class Point : public Entity -{ -public: - Point(int x, int y); - - int getPosX() {return x;}; - int getPosY() {return y;}; - bool isCollidable() override { return false; }; - void render() const override { - //system("color 0A"); - std::cout << "\033[32mo\033[0m"; - } - -private: - int x, y; - int Position = 0; - - friend std::ostream& operator<<(std::ostream& os, const Point& point); -}; - - diff --git a/BoardGame/Snake.cpp b/BoardGame/Snake.cpp deleted file mode 100644 index 05e1ef4..0000000 --- a/BoardGame/Snake.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "Snake.h" - -void Snake::addSpeed(float speed) -{ - m_Speed += speed; -} -void Snake::removeSpeed(float speed) -{ - m_Speed -= speed; -} -int Snake::wrap(int value, int max) { - return (value + max) % max; -} - -void Snake::move(int direction) -{ - //gros pavé pour check si le joueur fait demi tour direct* - //[TODO] rendre lisible et optimisé - - direction = m_currentDirection; // on ignore si le joueur fait un 180° - int head = m_Body.front(); - int row = head / 16; - int col = head % 16; - - switch (direction) - { - case 1: col--; break; - case 2: row--; break; - case 3: col++; break; - case 4: row++; break; - } - - row = wrap(row, 16); - col = wrap(col, 16); - - int newHead = row * 16 + col; - - // check la collision on skip la tete sinon probleme - for (size_t i = 1; i < m_Body.size(); ++i) - { - if (newHead == m_Body[i]) - { - std::cout << "Parti fini" << "\n"; - exit(0); // on quitte pour l'instant - //[TODO] faire un menu et un écran de fin - } - } - - for (int i = m_Body.size() - 1; i > 0; --i) - { - m_Body[i] = m_Body[i - 1]; - } - - m_Body[0] = newHead; - Position = newHead; - -} - - -std::ostream& operator<<(std::ostream& os, const Snake& snake) -{ - os << "~"; - return os; -} diff --git a/BoardGame/Snake.h b/BoardGame/Snake.h deleted file mode 100644 index d7e610b..0000000 --- a/BoardGame/Snake.h +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once -#include "stdafx.h" -#include "Entity.h" - - -class Snake : public Entity -{ -public: - Snake(float speed, int score, int startPosition) - : m_Speed(speed), m_Score(score) - { - m_Body.push_back(startPosition); - Position = startPosition; - isAlive = true; - } - void addSegment(int count) - { - for (int i = 0; i < count; ++i) - { - m_Body.push_back(m_Body.back()); //rajout d'un segment dans la derniere position - } - } - - - void addSpeed(float speed); - - void removeSpeed(float speed); - - float getSpeed() { return m_Speed; }; - - void move(int direction); - - void render() const override { - //system("color 0C"); - std::cout << "\033[34m~\033[0m"; //ANSI code color pour changement de la couleur dans terminal - } - - void setPosition(int pos) { position = pos; }; - - int getPosition() const { return m_Body[0]; } - - bool isCollidable() override { return true; }; - - void addScore(int score) { this->m_Score += score; }; - - int getScore() { return m_Score; }; - std::vector getBody() { return m_Body; }; - int wrap(int value, int max); - bool getAlive() { return isAlive; }; - void setCurrentDirection(int direction) {this->m_currentDirection = direction;}; - int getCurrentDirection() { return m_currentDirection; }; - void setNextDirection(int nextDirection) {this->m_nextDirection = nextDirection; }; - int getNextDirection() { return m_nextDirection; }; - bool isOpposite(int dir1, int dir2) { - return (dir1 == 1 && dir2 == 3) || (dir1 == 3 && dir2 == 1) || - (dir1 == 2 && dir2 == 4) || (dir1 == 4 && dir2 == 2); - } - - - bool canChangeDirection = true; - - -private: - - float m_Speed = 3.0f*(0.3*m_Length);//[TODO] rendre modulable si ajout difficulter - int m_Length = 1; - int position; - const int _OFFSET = 16; - int m_Score = 0; - int m_currentDirection = 1; - int m_nextDirection = 3; - bool isAlive; - - - - - std::vector m_Body;//liste des segments du serpent - friend std::ostream& operator<<(std::ostream& os, const Snake& snake); - - - -}; - - - - - - diff --git a/BoardGame/bitmap.png b/BoardGame/bitmap.png deleted file mode 100644 index 1cfb2cc..0000000 Binary files a/BoardGame/bitmap.png and /dev/null differ diff --git a/BoardGame/bitmap.txt b/BoardGame/bitmap.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/board.cpp b/src/board.cpp new file mode 100644 index 0000000..f7ec4d6 --- /dev/null +++ b/src/board.cpp @@ -0,0 +1,60 @@ +#include "stdafx.h" + +#include "board.hpp" +#include "fruit.hpp" +#include "snake.hpp" + +namespace snake { + +namespace { + std::random_device rd; + std::mt19937 gen(rd()); +} + +Board::Board() + : snake(5.0f, 1, Index{150}) + , fruit(Index{0}) +{ + for (auto pos : snake.body) + { + board[pos.idx] = Entity::Kind::snake; + } + spawnFruit(); +} + +void Board::moveSnake() +{ + auto last = snake.last(); + + snake.move(); + if (snake.head() == fruit.pos) + { + snake.score += fruit.points; + spawnFruit(); + snake.grow(); + } + + board[last.idx] = Entity::Kind::none; + board[snake.last().idx] = Entity::Kind::snake; // in case snake.last() == last (like grow) + board[snake.head().idx] = Entity::Kind::snake; +} + +void Board::spawnFruit() +{ + std::vector emptyPositions; + for (int i = 0; i < int(board.size()); i++) + { + if (board[i] == Entity::Kind::none) + { + emptyPositions.push_back(Index{i}); + } + } + + if (emptyPositions.empty()) + exit(0); // todo: win? + + fruit.pos = emptyPositions[std::uniform_int_distribution<>(0, int(emptyPositions.size()) - 1)(gen)]; + board[fruit.pos.idx] = Entity::Kind::fruit; +} + +} // namespace snake \ No newline at end of file diff --git a/src/board.hpp b/src/board.hpp new file mode 100644 index 0000000..42abf5e --- /dev/null +++ b/src/board.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "fruit.hpp" +#include "snake.hpp" + +namespace snake { + +class Board +{ +public: + Board(); + + void moveSnake(); + void spawnFruit(); + + Snake snake; + Fruit fruit; + + std::array board; +}; + +} // namespace snake \ No newline at end of file diff --git a/src/entity.hpp b/src/entity.hpp new file mode 100644 index 0000000..735cdfe --- /dev/null +++ b/src/entity.hpp @@ -0,0 +1,67 @@ +#pragma once + +namespace snake { + +constexpr int boardSize = 16; + +struct Index; + +struct Pos { + int x = 0; + int y = 0; + + Pos(int x, int y) : x(x), y(y) {} + Pos(int index) : x(index % boardSize), y(index / boardSize) {} + Pos(Index index); + + void wrap() { + x = (x + boardSize) % boardSize; + y = (y + boardSize) % boardSize; + } +}; + +struct Index { + int idx = 0; + + Index(int idx) : idx(idx) {} + Index(int x, int y) : idx(y * boardSize + x) {} + Index(Pos p) : Index(p.x, p.y) {} + + constexpr bool operator==(Index const&) const noexcept = default; +}; + +inline Pos::Pos(Index index) : Pos(index.idx) {} + +enum class Direction { + left, + up, + right, + down, +}; + +constexpr bool isColinear(Direction a, Direction b) noexcept +{ + unsigned const aa = unsigned(a) & 0b1; + unsigned const bb = unsigned(b) & 0b1; + return aa == bb; +} + +class Entity +{ +public: + enum class Kind : char { + none, + snake, + fruit, + }; + + //Kind const kind; // it's never used + +protected: + Entity(Kind /*kind*/) + //: kind(kind) + { + } +}; + +} // namespace snake \ No newline at end of file diff --git a/src/fruit.hpp b/src/fruit.hpp new file mode 100644 index 0000000..47b115c --- /dev/null +++ b/src/fruit.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "entity.hpp" + +namespace snake { + +class Fruit : public Entity +{ +public: + Fruit(Index pos) + : Entity(Kind::fruit) + , pos(pos) + { + } + + Index pos; + static constexpr int points = 1000; +}; + +} // namespace snake \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..f4f649d --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,258 @@ +#include "stdafx.h" + +#include "board.hpp" + +namespace snake { + +namespace { + +Board board; +int width = 0; +int height = 0; + +HDC backDC = nullptr; +HBITMAP backBuf = nullptr; + +int frames = 0; + +using clock = std::chrono::steady_clock; + +std::chrono::milliseconds periodUpdate; +clock::time_point lastUpdateTime; + +constexpr std::chrono::milliseconds periodDraw { 16 }; +clock::time_point lastDrawTime; + +clock::time_point lastFPSUpdateTime; +float fps = 0; +std::wstring fpsText; + +void draw(HDC hdc, float dt) +{ + int const squareWidth = width / boardSize; + int const squareHeight = height / boardSize; + + // assume mostly empty and accept larger overdraw as snake grows + { + auto const brush = CreateSolidBrush(RGB(0, 255, 0)); + RECT rect { 0, 0, width, height }; + FillRect(hdc, &rect, brush); + DeleteObject(brush); + } + + // fruit + { + auto const brush = CreateSolidBrush(RGB(255, 0, 0)); + Pos const p = board.fruit.pos; + RECT r = { + p.x * squareWidth, + p.y * squareHeight, + (p.x + 1) * squareWidth, + (p.y + 1) * squareHeight + }; + FillRect(hdc, &r, brush); + DeleteObject(brush); + } + + // snake + for (int i = 0, len = int(board.snake.bodyPrev.size()); i < len; ++i) { + HBRUSH brush = nullptr; + if (len > 1) + { + float const ratio = static_cast(i) / (len - 1); + int const brightness = static_cast(ratio * 200); + + int const red = brightness; + int const green = brightness; + int const blue = 255; + + brush = CreateSolidBrush(RGB(red, green, blue)); + } + else + { + brush = CreateSolidBrush(RGB(0, 0, 255)); + } + + // todo: wrapping from left to right draws the entire rect on the right + // when warping there should be 2 rect draws to show partially on both sides + Pos const p[2] { board.snake.body[i], board.snake.bodyPrev[i] }; + float dx = std::fmodf((p[0].x - p[1].x)*squareWidth + width /2.0f, float(width )) - width /2.0f; + float dy = std::fmodf((p[0].y - p[1].y)*squareHeight + height/2.0f, float(height)) - height/2.0f; + if (dx < -width /2.0f) dx += width; + if (dy < -height/2.0f) dy += height; + int x = int(std::fmodf(p[1].x*squareWidth + dx*dt + width , float(width ))); + int y = int(std::fmodf(p[1].y*squareHeight + dy*dt + height, float(height))); + RECT rect = { + x, y, + x + squareWidth, y + squareHeight + }; + + FillRect(hdc, &rect, brush); + DeleteObject(brush); + + std::wstring text = std::to_wstring(i); + SetBkMode(hdc, TRANSPARENT); + DrawText(hdc, text.c_str(), -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); + } + + TextOut(hdc, 10, 10, fpsText.c_str(), int(fpsText.length())); +} + +void update() +{ + auto const now = clock::now(); + if (now - lastUpdateTime >= periodUpdate) + { + board.moveSnake(); + lastUpdateTime = now; + } +} + +void sleepTargetDrawPeriod() +{ + std::this_thread::sleep_for(std::chrono::milliseconds(1)); +} + +LRESULT CALLBACK windowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_CREATE: + periodUpdate = std::chrono::milliseconds{ 50 - int(board.snake.speed) }; + return 0; + + case WM_DESTROY: + if (backDC) DeleteDC(backDC); + if (backBuf) DeleteObject(backBuf); + PostQuitMessage(0); + return 0; + + case WM_SIZE: + { + width = LOWORD(lParam); + height = HIWORD(lParam); + + auto hdc = GetDC(hwnd); + if (backDC) DeleteDC(backDC); + backDC = CreateCompatibleDC(hdc); + + if (backBuf) DeleteObject(backBuf); + backBuf = CreateCompatibleBitmap(hdc, width, height); + + SelectObject(backDC, backBuf); + ReleaseDC(hwnd, hdc); + } + return 0; + + case WM_PAINT: + { + auto now = clock::now(); + PAINTSTRUCT ps; + auto hdc = BeginPaint(hwnd, &ps); + auto const dt = std::chrono::duration(now - lastUpdateTime).count() / std::chrono::duration(periodUpdate).count(); + draw(backDC, dt); + BitBlt(hdc, 0, 0, width, height, backDC, 0, 0, SRCCOPY); + EndPaint(hwnd, &ps); + lastDrawTime = clock::now(); + + frames++; + + float elapsed = std::chrono::duration(lastDrawTime - lastFPSUpdateTime).count(); + if (elapsed >= 1) { + fps = float(frames) / elapsed; + frames = 0; + lastFPSUpdateTime = lastDrawTime; + + fpsText = L"FPS: " + std::to_wstring(fps); + std::wstring title = L"Snake - FPS: " + std::to_wstring(fps); + SetWindowText(hwnd, title.c_str()); + } + } + return 0; + + case WM_KEYDOWN: + { + auto& snake = board.snake; + auto desiredDirection = snake.direction; + + switch (wParam) + { +#ifdef SNAKE_USE_CURSOR_KEYS + case VK_LEFT : desiredDirection = Direction::left ; break; + case VK_UP : desiredDirection = Direction::up ; break; + case VK_RIGHT: desiredDirection = Direction::right; break; + case VK_DOWN : desiredDirection = Direction::down ; break; +#else + case 'Q': desiredDirection = Direction::left ; break; + case 'Z': desiredDirection = Direction::up ; break; + case 'D': desiredDirection = Direction::right; break; + case 'S': desiredDirection = Direction::down ; break; +#endif + } + + if (!isColinear(snake.direction, desiredDirection)) + { + snake.direction = desiredDirection; + } + } + return 0; + + } + return DefWindowProc(hwnd, uMsg, wParam, lParam); +} + +HWND createMainWindow(WNDPROC proc) +{ + const wchar_t CLASS_NAME[] = L"SnakeWindow"; + + WNDCLASS wc = {}; + wc.lpfnWndProc = proc; + wc.hInstance = GetModuleHandle(NULL); + wc.lpszClassName = CLASS_NAME; + + RegisterClass(&wc); + + HWND hwnd = CreateWindowEx( + 0, CLASS_NAME, L"Snake", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, GetModuleHandle(NULL), NULL + ); + + if (hwnd != NULL) { + ShowWindow(hwnd, SW_SHOW); + } + + return hwnd; +} + +} // namespace + +} // namespace snake + +int WINAPI wWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, PWSTR /*pCmdLine*/, int /*nCmdShow*/) +{ + auto hwnd = snake::createMainWindow(snake::windowProc); + if (!hwnd) + return 1; + + for (;;) + { + for (MSG msg {}; PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE); ) + { + if (msg.message == WM_QUIT) + goto L_quit; + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + snake::update(); + + InvalidateRect(hwnd, nullptr, FALSE); + UpdateWindow(hwnd); + + snake::sleepTargetDrawPeriod(); + } + +L_quit: + return 0; +} \ No newline at end of file diff --git a/src/snake.cpp b/src/snake.cpp new file mode 100644 index 0000000..306d69e --- /dev/null +++ b/src/snake.cpp @@ -0,0 +1,49 @@ +#include "stdafx.h" + +#include "snake.hpp" + +namespace snake { + +void Snake::grow(int count) +{ + body.reserve(body.size() + count); + auto const p = body.back(); + for (int i = 0; i < count; ++i) + { + body.push_back(p); + } +} + +void Snake::move() +{ + bodyPrev = body; + + Pos p = head(); + switch (direction) + { + case Direction::left : p.x--; break; + case Direction::up : p.y--; break; + case Direction::right: p.x++; break; + case Direction::down : p.y++; break; + } + + p.wrap(); + + Index newHead = p; + for (size_t i = 1; i < body.size(); ++i) + { + if (newHead == body[i]) + { + exit(0); // todo: lose + } + } + + for (int i = size() - 1; i > 0; --i) + { + body[i] = body[i - 1]; + } + + body[0] = newHead; +} + +} // namespace snake \ No newline at end of file diff --git a/src/snake.hpp b/src/snake.hpp new file mode 100644 index 0000000..b94dae1 --- /dev/null +++ b/src/snake.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "entity.hpp" + +namespace snake { + +class Snake : public Entity +{ +public: + Snake(float speed, int score, Index pos) + : Entity(Kind::snake) + , speed(speed) + , score(score) + , body{ pos } + { + } + + void grow(int count = 1); + void move(); + + Index head() const { return body.front(); } + Index last() const { return body.back(); } + int size() const { return int(body.size()); } + + float speed = 1.0f; + int score = 0; + + Direction direction = Direction::right; + + std::vector body; + std::vector bodyPrev; +}; + +} // namespace snake \ No newline at end of file diff --git a/BoardGame/stdafx.h b/src/stdafx.h similarity index 52% rename from BoardGame/stdafx.h rename to src/stdafx.h index a34479a..829545d 100644 --- a/BoardGame/stdafx.h +++ b/src/stdafx.h @@ -1,10 +1,18 @@ #pragma once -#include -#include -#include -#include + #include -#include + +#include +#include +#include + +#include +#include +#include +#include #include +#include +#include +#include #include -#include +#include \ No newline at end of file diff --git a/vc/snake.sln b/vc/snake.sln new file mode 100644 index 0000000..1287059 --- /dev/null +++ b/vc/snake.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36121.58 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "snake", "snake.vcxproj", "{DE726747-E9F3-4EC5-AF95-079BE135692A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Debug|x64.ActiveCfg = Debug|x64 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Debug|x64.Build.0 = Debug|x64 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Debug|x86.ActiveCfg = Debug|Win32 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Debug|x86.Build.0 = Debug|Win32 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Release|x64.ActiveCfg = Release|x64 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Release|x64.Build.0 = Release|x64 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Release|x86.ActiveCfg = Release|Win32 + {DE726747-E9F3-4EC5-AF95-079BE135692A}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A74185CC-97AC-4082-AB9A-6D0ED3A8EA51} + EndGlobalSection +EndGlobal diff --git a/BoardGame/BoardGame.vcxproj b/vc/snake.vcxproj similarity index 70% rename from BoardGame/BoardGame.vcxproj rename to vc/snake.vcxproj index f76742a..199e05c 100644 --- a/BoardGame/BoardGame.vcxproj +++ b/vc/snake.vcxproj @@ -1,147 +1,162 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {19a76af3-0481-4ccc-b842-42ae45ca36ff} - BoardGame - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {de726747-e9f3-4ec5-af95-079be135692a} + snake + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)x\$(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)x\$(Platform)\$(Configuration)\ + + + $(SolutionDir)x\$(Platform)\$(Configuration)\ + + + $(SolutionDir)x\$(Platform)\$(Configuration)\ + + + + Level4 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);SNAKE_USE_CURSOR_KEYS + true + stdcpp20 + Create + + + Windows + true + + + + + Level4 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);SNAKE_USE_CURSOR_KEYS + true + stdcpp20 + Create + + + Windows + true + + + + + Level4 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);SNAKE_USE_CURSOR_KEYS + true + stdcpp20 + Create + + + Windows + true + + + + + Level4 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions);SNAKE_USE_CURSOR_KEYS + true + stdcpp20 + Create + + + Windows + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vc/snake.vcxproj.filters b/vc/snake.vcxproj.filters new file mode 100644 index 0000000..87dd723 --- /dev/null +++ b/vc/snake.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {24f6694e-79e9-40c7-b160-1c97ee56c0ba} + + + + + src + + + src + + + src + + + + + src + + + src + + + src + + + src + + + src + + + \ No newline at end of file