Files
jminos/src/Pieces/Color.h
2025-02-25 19:21:08 +01:00

48 lines
841 B
C++

#pragma once
#include <string>
/**
* Every possible colors a block can take
*/
enum ColorEnum {
NOTHING,
OUT_OF_BOUNDS,
GARBAGE,
PURPLE,
ORANGE,
CYAN,
PINK,
YELLOW,
RED,
BLUE,
GREEN
};
struct Color {
std::uint8_t r;
std::uint8_t g;
std::uint8_t b;
};
/**
* Returns the first color a piece can take
*/
inline ColorEnum firstPieceColor() {
return ColorEnum::PURPLE;
}
const Color& getColor(ColorEnum color);
/**
* Sets the color to the next available piece color
*/
void setNextPieceColor(ColorEnum& color);
inline std::string getColorCode(const Color& color) {
return "\033[38;2;" + std::to_string(color.r) + ";" + std::to_string(color.g) + ";" + std::to_string(color.b) + "m";
}
inline std::string getColorCode(ColorEnum color) {
return getColorCode(color);
}