diff --git a/Makefile b/Makefile index e75d79c..bfbf9d9 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ SNAKE_SRC = src/snake/Entities/Void.cpp \ classes/Timer.cpp \ classes/Color.cpp \ -NCURSES_SRC = src/ncurses/ncurses.cpp \ +NCURSES_SRC = src/ncurses/Ncurses.cpp \ SFML_SRC = src/sfml/Sfml.cpp \ diff --git a/abstract/AGame.hpp b/abstract/AGame.hpp index 85f1fcb..d341438 100644 --- a/abstract/AGame.hpp +++ b/abstract/AGame.hpp @@ -12,21 +12,21 @@ namespace Arcade { class AGame : public IGame { public: - virtual ~AGame() = default; + ~AGame() override = default; //Game - virtual int startGame() = 0; - virtual int stopGame() = 0; - int getScore(); - virtual int simulate() = 0; + int startGame() override = 0; + int stopGame() override = 0; + int getScore() override; + int simulate() override = 0; //Event - virtual void catchKeyEvent(int key) = 0; + void catchKeyEvent(int key) override = 0; //Display - std::vector> getEntities(); - std::vector> getTexts(); - std::vector> getSounds(); + std::vector> getEntities() override; + std::vector> getTexts() override; + std::vector> getSounds() override; protected: std::vector> _entities; diff --git a/classes/Color.hpp b/classes/Color.hpp index 14ecf07..7c4df50 100644 --- a/classes/Color.hpp +++ b/classes/Color.hpp @@ -13,14 +13,14 @@ namespace Arcade { class Color : public IColor { public: Color(short r, short g, short b, short a); - ~Color() = default; + ~Color() override = default; - void setColor(short r, short g, short b, short a); + void setColor(short r, short g, short b, short a) override; - short getR(); - short getG(); - short getB(); - short getA(); + short getR() override; + short getG() override; + short getB() override; + short getA() override; private: short _r; diff --git a/classes/Text.hpp b/classes/Text.hpp index 349a483..1b1f0a8 100644 --- a/classes/Text.hpp +++ b/classes/Text.hpp @@ -14,22 +14,22 @@ namespace Arcade { class Text : public IText { public: Text(std::string text, std::vector pos, std::vector size, char c); - ~Text() = default; + ~Text() override = default; - void setFontPath(const std::string &fontPath); - void setText(const std::string &text); - void setColor(std::unique_ptr color); - void setPos(std::size_t x, std::size_t y); - void setSize(std::size_t x); - void setRotation(float rotation); + void setFontPath(const std::string &fontPath) override; + void setText(const std::string &text) override; + void setColor(std::unique_ptr color) override; + void setPos(std::size_t x, std::size_t y) override; + void setSize(std::size_t x) override; + void setRotation(float rotation) override; //getters - std::string getFontPath(); - std::string getText(); - std::shared_ptr getColor() const; - std::vector getPos() const; - std::size_t getSize() const; - float getRotation() const; + std::string getFontPath() override; + std::string getText() override; + std::shared_ptr getColor() const override; + std::vector getPos() const override; + std::size_t getSize() const override; + float getRotation() const override; private: std::string _text; std::vector _pos; diff --git a/src/ncurses/Ncurses.cpp b/src/ncurses/Ncurses.cpp new file mode 100644 index 0000000..3c60237 --- /dev/null +++ b/src/ncurses/Ncurses.cpp @@ -0,0 +1,192 @@ +/* +** EPITECH PROJECT, 2024 +** Arcade +** File description: +** ncurses.cpp +*/ + +#include "Ncurses.hpp" +#include "includes/Keys.hpp" +#include +#include +#include +#include + + +Arcade::Ncurses::Ncurses() +{ + initscr(); + noecho(); + keypad(stdscr, TRUE); + nodelay(stdscr, TRUE); + curs_set(0); + start_color(); + init_color(COLOR_BLACK, 0, 0, 0); + init_pair(1, COLOR_WHITE, COLOR_BLACK); + init_pair(2, COLOR_RED, COLOR_BLACK); + init_pair(3, COLOR_GREEN, COLOR_BLACK); + init_pair(4, COLOR_BLUE, COLOR_BLACK); + init_pair(5, COLOR_YELLOW, COLOR_BLACK); + init_pair(6, COLOR_MAGENTA, COLOR_BLACK); + init_pair(7, COLOR_CYAN, COLOR_BLACK); + init_pair(8, COLOR_WHITE, COLOR_BLACK); + wbkgd(stdscr, COLOR_PAIR(1)); + +} + +bool Arcade::Ncurses::isWindowOpen() const +{ + return true; +} + +void Arcade::Ncurses::closeWindow() +{ + endwin(); +} + +void Arcade::Ncurses::clearWindow() +{ + for (int i = 0; i < LINES; i++) { + for (int j = 0; j < COLS; j++) { + mvprintw(i, j, " "); + } + } +} + +int Arcade::Ncurses::getKeyEvent() +{ + int key = getch(); + static std::map keyMap = { + {'A', Arcade::Keys::A}, + {'B', Arcade::Keys::B}, + {'C', Arcade::Keys::C}, + {'D', Arcade::Keys::D}, + {'E', Arcade::Keys::E}, + {'F', Arcade::Keys::F}, + {'G', Arcade::Keys::G}, + {'H', Arcade::Keys::H}, + {'I', Arcade::Keys::I}, + {'J', Arcade::Keys::J}, + {'K', Arcade::Keys::K}, + {'L', Arcade::Keys::L}, + {'M', Arcade::Keys::M}, + {'N', Arcade::Keys::N}, + {'O', Arcade::Keys::O}, + {'P', Arcade::Keys::P}, + {'Q', Arcade::Keys::Q}, + {'R', Arcade::Keys::R}, + {'S', Arcade::Keys::S}, + {'T', Arcade::Keys::T}, + {'U', Arcade::Keys::U}, + {'V', Arcade::Keys::V}, + {'W', Arcade::Keys::W}, + {'X', Arcade::Keys::X}, + {'Y', Arcade::Keys::Y}, + {'Z', Arcade::Keys::Z}, + {'1', Arcade::Keys::ONE}, + {'2', Arcade::Keys::TWO}, + {'3', Arcade::Keys::THREE}, + {'4', Arcade::Keys::FOUR}, + {'5', Arcade::Keys::FIVE}, + {'6', Arcade::Keys::SIX}, + {'7', Arcade::Keys::SEVEN}, + {'8', Arcade::Keys::EIGHT}, + {'9', Arcade::Keys::NINE}, + {'0', Arcade::Keys::ZERO}, + {27, Arcade::Keys::ESCAPE}, + {9, Arcade::Keys::TAB}, + {KEY_BACKSPACE, Arcade::Keys::BACKSPACE}, + {KEY_UP, Arcade::Keys::UP}, + {KEY_DOWN, Arcade::Keys::DOWN}, + {KEY_LEFT, Arcade::Keys::LEFT}, + {KEY_RIGHT, Arcade::Keys::RIGHT}, + {10, Arcade::Keys::ENTER}, + {32, Arcade::Keys::SPACE}, + {KEY_MOUSE, Arcade::Keys::MOUSE_LEFT} + }; + return keyMap[key]; +} + +std::pair Arcade::Ncurses::getMousePosition() +{ + MEVENT event; + if (getmouse(&event) == OK) { + return {event.x * 29 , event.y * 29}; + } + return {-1, -1}; +} + +void Arcade::Ncurses::displayWindow() +{ + refresh(); +} + +int Arcade::Ncurses::colorToNcurses(const std::shared_ptr& color) +{ + int bestColor = 1; + double minDistance = 1000000; + + std::map> colors = { + {1, {255, 255, 255, 255}}, + {2, {255, 0, 0, 255}}, + {3, {0, 255, 0, 255}}, + {4, {0, 0, 255, 255}}, + {5, {255, 255, 0, 255}}, + {6, {255, 0, 255, 255}}, + {7, {0, 255, 255, 255}}, + {8, {255, 255, 255, 255}} + + }; + + for (auto &colorPair : colors) { + double distance = sqrt(pow(std::get<0>(colorPair.second) - color->getR(), 2) + pow(std::get<1>(colorPair.second) - color->getG(), 2) + pow(std::get<2>(colorPair.second) - color->getB(), 2)); + if (distance < minDistance) { + minDistance = distance; + bestColor = colorPair.first; + } + } + return bestColor; +} + +void Arcade::Ncurses::displayEntities(std::vector> entities) +{ + for (auto &entity : entities) { + int x = colorToNcurses(entity->getColor()); + wattron(stdscr, COLOR_PAIR(x)); + mvwaddch(stdscr, entity->getPos()[1], entity->getPos()[0], (char)entity->getChar()); + wattroff(stdscr, COLOR_PAIR(x)); + } +} + +void Arcade::Ncurses::displayText(std::vector> texts) +{ + for (auto &text : texts) { + int x = colorToNcurses(text->getColor()); + if (text->getFontPath().empty()) + continue; + wattron(stdscr, COLOR_PAIR(x)); + mvprintw(text->getPos()[1], text->getPos()[0], "%s", text->getText().c_str()); + wattroff(stdscr, COLOR_PAIR(x)); + } +} + +void Arcade::Ncurses::playSound(std::vector> sounds) +{ + (void)sounds; +} + +extern "C" +{ + __attribute__((constructor)) + void constructor() + { + } + __attribute__((destructor)) + void destructor() + { + } + Arcade::Ncurses *loadGraphicInstance() + { + return new Arcade::Ncurses(); + } +} diff --git a/src/ncurses/ncurses.hpp b/src/ncurses/Ncurses.hpp similarity index 71% rename from src/ncurses/ncurses.hpp rename to src/ncurses/Ncurses.hpp index 9af622a..62dd6f5 100644 --- a/src/ncurses/ncurses.hpp +++ b/src/ncurses/Ncurses.hpp @@ -9,26 +9,28 @@ #include "Interfaces/IGraphic.hpp" #include "includes/Keys.hpp" +#include namespace Arcade { class Ncurses : public IGraphic { public: Ncurses(); - ~Ncurses() = default; + ~Ncurses() override = default; bool isWindowOpen() const override; - void closeWindow(); - void clearWindow(); + void closeWindow() override; + void clearWindow() override; //Event int getKeyEvent() override; - std::pair getMousePosition(); + std::pair getMousePosition() override; //Display - void displayWindow(); + void displayWindow() override; void displayEntities(std::vector> entities) override; void displayText(std::vector> texts) override; void playSound(std::vector> sounds) override; private: + static int colorToNcurses(const std::shared_ptr& color); std::vector _entities; std::vector _texts; std::vector _sounds; diff --git a/src/ncurses/ncurses.cpp b/src/ncurses/ncurses.cpp deleted file mode 100644 index e498d2f..0000000 --- a/src/ncurses/ncurses.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -** EPITECH PROJECT, 2024 -** Arcade -** File description: -** ncurses.cpp -*/ - -#include "ncurses.hpp" -#include "includes/Keys.hpp" -#include -#include - -int init(void) -{ - return 0; -} - -Arcade::Ncurses::Ncurses() -{ -} - -bool Arcade::Ncurses::isWindowOpen() const -{ - return false; -} - -void Arcade::Ncurses::closeWindow() -{ -} - -void Arcade::Ncurses::clearWindow() -{ -} - -int Arcade::Ncurses::getKeyEvent() -{ - return Keys::A; -} - -void Arcade::Ncurses::displayWindow() -{ -} - -void Arcade::Ncurses::displayEntities(std::vector> entities) -{ - (void)entities; -} - -void Arcade::Ncurses::displayText(std::vector> texts) -{ - (void)texts; -} - -void Arcade::Ncurses::playSound(std::vector> sounds) -{ - (void)sounds; -} - -std::pair Arcade::Ncurses::getMousePosition() -{ - return std::make_pair(0, 0); -} - -extern "C" -{ - __attribute__((constructor)) - void constructor() - { - } - __attribute__((destructor)) - void destructor() - { - } - Arcade::Ncurses *loadGraphicInstance() - { - return new Arcade::Ncurses(); - } -} diff --git a/src/pacman/pacman.cpp b/src/pacman/pacman.cpp index 48d8663..56eb3c4 100644 --- a/src/pacman/pacman.cpp +++ b/src/pacman/pacman.cpp @@ -36,11 +36,6 @@ void Arcade::Pacman::catchKeyEvent(int key) (void)key; } -void Arcade::Pacman::catchMousePosition(int x, int y) -{ - (void)x; - (void)y; -} std::vector> Arcade::Pacman::getEntities() { @@ -57,6 +52,12 @@ std::vector> Arcade::Pacman::getSounds() return std::vector>(); } +void Arcade::Pacman::catchMousePosition(int x, int y) +{ + (void)x; + (void)y; +} + extern "C" { __attribute__((constructor)) diff --git a/src/pacman/pacman.hpp b/src/pacman/pacman.hpp index 105ecac..18367de 100644 --- a/src/pacman/pacman.hpp +++ b/src/pacman/pacman.hpp @@ -24,7 +24,7 @@ namespace Arcade { //Event void catchKeyEvent(int key); void catchMousePosition(int x, int y); - + //Display std::vector> getEntities(); std::vector> getTexts(); diff --git a/src/sdl/Sdl.hpp b/src/sdl/Sdl.hpp index eb06691..d9bc320 100644 --- a/src/sdl/Sdl.hpp +++ b/src/sdl/Sdl.hpp @@ -6,40 +6,42 @@ */ #pragma once - -#include "Interfaces/IGraphic.hpp" #include "includes/Keys.hpp" #include #include #include -#include -#include +#include #include +#include +#include "Interfaces/IGraphic.hpp" +#include "Interfaces/IEntity.hpp" +#include "Interfaces/IText.hpp" +#include "Interfaces/ISound.hpp" namespace Arcade { class Sdl : public IGraphic { - public: - Sdl(); - ~Sdl(); - bool isWindowOpen() const override; - void closeWindow() override; - void clearWindow() override; - - //Event - int getKeyEvent() override; - std::pair getMousePosition() override; + public: + Sdl(); + ~Sdl(); + bool isWindowOpen() const override; + void closeWindow(); + void clearWindow(); - //Display - void displayWindow() override; - void displayEntities(std::vector> entities) override; - void displayText(std::vector> texts) override; - void playSound(std::vector> sounds) override; - private: - std::vector _entities; - std::vector _texts; - std::vector _sounds; - SDL_Window *_window; - SDL_Renderer *_renderer; + //Event + int getKeyEvent() override; + std::pair getMousePosition(); + //Display + void displayWindow(); + void displayEntities(std::vector> entities) override; + void displayText(std::vector> texts) override; + void playSound(std::vector> sounds) override; + private: + std::vector _entities; + std::vector _texts; + std::vector _sounds; + Keys _key; + SDL_Window *_window; + SDL_Renderer *_renderer; }; } diff --git a/src/snake/Entities/Food.cpp b/src/snake/Entities/Food.cpp index b8eae44..9d0dff0 100644 --- a/src/snake/Entities/Food.cpp +++ b/src/snake/Entities/Food.cpp @@ -40,7 +40,7 @@ Arcade::Food::Food(Arcade::Snake snake) _path = FOOD_PATH; _rotation = 0; _char = 'O'; - _color = std::make_unique(40, 79, 42, 255); + _color = std::make_unique(175, 79, 42, 255); } void Arcade::Food::setPos(std::size_t x, std::size_t y) diff --git a/src/snake/Entities/Food.hpp b/src/snake/Entities/Food.hpp index 67a78d6..f25fb33 100644 --- a/src/snake/Entities/Food.hpp +++ b/src/snake/Entities/Food.hpp @@ -13,24 +13,24 @@ namespace Arcade { class Food : public IEntity { public: - Food(Snake snake); - ~Food() = default; + explicit Food(Snake snake); + ~Food() override = default; //setters - void setPos(std::size_t x, std::size_t y); - void setSize(std::size_t x, std::size_t y); - void setChar(char c); - void setColor(std::unique_ptr color); - void setPath(const std::string &path); - void setRotation(float rotation); + void setPos(std::size_t x, std::size_t y) override; + void setSize(std::size_t x, std::size_t y) override; + void setChar(char c) override; + void setColor(std::unique_ptr color) override; + void setPath(const std::string &path) override; + void setRotation(float rotation) override; - //getters - std::vector getPos() const; - std::vector getSize() const; - int getChar() const; - std::shared_ptr getColor() const; - std::string getPath() const; - float getRotation() const; + //getter + std::vector getPos() const override; + std::vector getSize() const override; + int getChar() const override; + std::shared_ptr getColor() const override; + std::string getPath() const override; + float getRotation() const override; private: std::vector _pos; diff --git a/src/snake/Entities/SnakeBody.cpp b/src/snake/Entities/SnakeBody.cpp index c41181d..92a7fb9 100644 --- a/src/snake/Entities/SnakeBody.cpp +++ b/src/snake/Entities/SnakeBody.cpp @@ -16,7 +16,7 @@ Arcade::SnakeBody::SnakeBody(std::size_t x, std::size_t y, std::string path, Dir _size = {29, 29}; _path = path; _char = '='; - _color = std::make_unique(39, 122, 16, 255); + _color = std::make_unique(200, 200, 16, 255); _direction = dir; updateRotation(); } diff --git a/src/snake/Entities/SnakeBody.hpp b/src/snake/Entities/SnakeBody.hpp index 61a5e64..4732a9c 100644 --- a/src/snake/Entities/SnakeBody.hpp +++ b/src/snake/Entities/SnakeBody.hpp @@ -15,25 +15,25 @@ namespace Arcade { class SnakeBody : public IEntity { public: SnakeBody(std::size_t x, std::size_t y, std::string path, Direction dir); - ~SnakeBody() = default; + ~SnakeBody() override = default; //setters - void setPos(std::size_t x, std::size_t y); - void setSize(std::size_t x, std::size_t y); - void setChar(char c); - void setColor(std::unique_ptr color); - void setPath(const std::string &path); - void setRotation(float rotation); + void setPos(std::size_t x, std::size_t y) override; + void setSize(std::size_t x, std::size_t y) override; + void setChar(char c) override; + void setColor(std::unique_ptr color) override; + void setPath(const std::string &path) override; + void setRotation(float rotation) override; void setDirection(Direction dir); void updateRotation(); - //getters - std::vector getPos() const; - std::vector getSize() const; - int getChar() const; - std::shared_ptr getColor() const; - std::string getPath() const; - float getRotation() const; + //getter + std::vector getPos() const override; + std::vector getSize() const override; + int getChar() const override; + std::shared_ptr getColor() const override; + std::string getPath() const override; + float getRotation() const override; Direction getDirection() const; private: diff --git a/src/snake/Entities/Void.hpp b/src/snake/Entities/Void.hpp index b40c777..c5f194d 100644 --- a/src/snake/Entities/Void.hpp +++ b/src/snake/Entities/Void.hpp @@ -13,23 +13,23 @@ namespace Arcade { class Void : public IEntity { public: Void(std::size_t x, std::size_t y); - ~Void() = default; + ~Void() override = default; //setters - void setPos(std::size_t x, std::size_t y); - void setSize(std::size_t x, std::size_t y); - void setChar(char c); - void setColor(std::unique_ptr color); - void setPath(const std::string &path); - void setRotation(float rotation); + void setPos(std::size_t x, std::size_t y) override; + void setSize(std::size_t x, std::size_t y) override; + void setChar(char c) override; + void setColor(std::unique_ptr color) override; + void setPath(const std::string &path) override; + void setRotation(float rotation) override; - //getters - std::vector getPos() const; - std::vector getSize() const; - int getChar() const; - std::shared_ptr getColor() const; - std::string getPath() const; - float getRotation() const; + //getter overrides + std::vector getPos() const override; + std::vector getSize() const override; + int getChar() const override; + std::shared_ptr getColor() const override; + std::string getPath() const override; + float getRotation() const override; private: std::vector _pos; diff --git a/src/snake/Entities/Wall.hpp b/src/snake/Entities/Wall.hpp index d674e2a..af4d8e9 100644 --- a/src/snake/Entities/Wall.hpp +++ b/src/snake/Entities/Wall.hpp @@ -13,23 +13,23 @@ namespace Arcade { class Wall : public IEntity { public: Wall(std::size_t x, std::size_t y); - ~Wall() = default; + ~Wall() override = default; //setters - void setPos(std::size_t x, std::size_t y); - void setSize(std::size_t x, std::size_t y); - void setChar(char c); - void setColor(std::unique_ptr color); - void setPath(const std::string &path); - void setRotation(float rotation); + void setPos(std::size_t x, std::size_t y) override; + void setSize(std::size_t x, std::size_t y) override; + void setChar(char c) override; + void setColor(std::unique_ptr color) override; + void setPath(const std::string &path) override; + void setRotation(float rotation) override; - //getters - std::vector getPos() const; - std::vector getSize() const; - int getChar() const; - std::shared_ptr getColor() const; - std::string getPath() const; - float getRotation() const; + //getter + std::vector getPos() const override; + std::vector getSize() const override; + int getChar() const override; + std::shared_ptr getColor() const override; + std::string getPath() const override; + float getRotation() const override; private: std::vector _pos; diff --git a/src/snake/Score.hpp b/src/snake/Score.hpp index 5f7527b..f988614 100644 --- a/src/snake/Score.hpp +++ b/src/snake/Score.hpp @@ -15,23 +15,23 @@ namespace Arcade { class Score : public IText { public: Score(); - ~Score() = default; + ~Score() override = default; // setters - void setFontPath(const std::string &fontPath); - void setText(const std::string &text); - void setColor(std::unique_ptr color); - void setPos(std::size_t x, std::size_t y); - void setSize(std::size_t x); - void setRotation(float rotation); + void setFontPath(const std::string &fontPath) override; + void setText(const std::string &text) override; + void setColor(std::unique_ptr color) override; + void setPos(std::size_t x, std::size_t y) override; + void setSize(std::size_t x) override; + void setRotation(float rotation) override; // getters - std::string getFontPath(); - std::string getText(); - std::shared_ptr getColor() const; - std::vector getPos() const; - std::size_t getSize() const; - float getRotation() const; + std::string getFontPath() override; + std::string getText() override; + std::shared_ptr getColor() const override; + std::vector getPos() const override; + std::size_t getSize() const override; + float getRotation() const override; int getScore() const; void incrementScore(); diff --git a/src/snake/SnakeGame.hpp b/src/snake/SnakeGame.hpp index 410ca6b..7f99970 100644 --- a/src/snake/SnakeGame.hpp +++ b/src/snake/SnakeGame.hpp @@ -31,22 +31,22 @@ namespace Arcade { class SnakeGame : public IGame { public: SnakeGame(); - ~SnakeGame() = default; + ~SnakeGame() override = default; //Game - int startGame(); - int stopGame(); - int getScore(); - int simulate(); + int startGame() override; + int stopGame() override; + int getScore() override; + int simulate() override; //Event - void catchKeyEvent(int key); - void catchMousePosition(int x, int y); + void catchKeyEvent(int key) override; + void catchMousePosition(int x, int y) override; //Display - std::vector> getEntities(); - std::vector> getTexts(); - std::vector> getSounds(); + std::vector> getEntities() override; + std::vector> getTexts() override; + std::vector> getSounds() override; private: std::vector> _entities; diff --git a/tests/snake/Entities/tests_food.cpp b/tests/snake/Entities/tests_food.cpp index e86131b..d23cd9a 100644 --- a/tests/snake/Entities/tests_food.cpp +++ b/tests/snake/Entities/tests_food.cpp @@ -23,7 +23,7 @@ Test(Food, DefaultConstructor) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); @@ -41,7 +41,7 @@ Test(Food, SetSizeAndGetSize) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); @@ -63,7 +63,7 @@ Test(Food, SetPosAndGetPos) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); @@ -85,7 +85,7 @@ Test(Food, SetCharAndGetChar) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); @@ -106,7 +106,7 @@ Test(Food, SetColorAndGetColor) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); @@ -130,7 +130,7 @@ Test(Food, SetPathAndGetPath) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); @@ -151,7 +151,7 @@ Test(Food, SetRotationAndGetRotation) cr_assert_eq(food.getPath(), FOOD_PATH); cr_assert_eq(food.getRotation(), 0); cr_assert_eq(food.getChar(), 'O'); - cr_assert_eq(food.getColor()->getR(), 40); + cr_assert_eq(food.getColor()->getR(), 175); cr_assert_eq(food.getColor()->getG(), 79); cr_assert_eq(food.getColor()->getB(), 42); cr_assert_eq(food.getColor()->getA(), 255); diff --git a/tests/snake/Entities/tests_snake_body.cpp b/tests/snake/Entities/tests_snake_body.cpp index 7e1a46c..1690404 100644 --- a/tests/snake/Entities/tests_snake_body.cpp +++ b/tests/snake/Entities/tests_snake_body.cpp @@ -22,8 +22,8 @@ Test(Snake, snake_constructor) cr_assert_eq(snake.getSize()[0], 29); cr_assert_eq(snake.getSize()[1], 29); cr_assert_eq(snake.getChar(), '='); - cr_assert_eq(snake.getColor()->getR(), 39); - cr_assert_eq(snake.getColor()->getG(), 122); + cr_assert_eq(snake.getColor()->getR(), 200); + cr_assert_eq(snake.getColor()->getG(), 200); cr_assert_eq(snake.getColor()->getB(), 16); cr_assert_eq(snake.getColor()->getA(), 255); } @@ -67,8 +67,8 @@ Test(Snake, setColor) { Arcade::SnakeBody snake = Arcade::SnakeBody(10, 10, "assets/body", Arcade::Direction::D_RIGHT); - cr_assert_eq(snake.getColor()->getR(), 39); - cr_assert_eq(snake.getColor()->getG(), 122); + cr_assert_eq(snake.getColor()->getR(), 200); + cr_assert_eq(snake.getColor()->getG(), 200); cr_assert_eq(snake.getColor()->getB(), 16); cr_assert_eq(snake.getColor()->getA(), 255); snake.setColor(std::make_unique(10, 20, 30, 40));