- [NEW] Esquemes de colors

This commit is contained in:
2024-07-02 18:20:16 +02:00
parent 33cfc7ee99
commit af6c5f43ef
4 changed files with 27 additions and 19 deletions

View File

@@ -974,9 +974,9 @@ namespace actor
draw::pushSource();
draw::setSource(act->surface);
if (editor::isEditing() && (act==selected)) draw::swapcol(1, room::getColor()==9?11:9); // Si està seleccionat, que canvie de color
if (editor::isEditing() && (act==selected)) draw::swapcol(1, room::getColor(1)); // Si està seleccionat, que canvie de color
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
draw::swapcol(1, room::getColor()); // Tornem al color per defecte
draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte
draw::popSource();
//print(x+5,y,act->pos.x);
//print(x+5,y+6,act->pos.y);

View File

@@ -373,9 +373,9 @@ bool game::loop()
draw::swapcol(1, WHITE+LIGHT);
actor::draw(actor::getPicked(), false);
const int col1 = 7+(room::getColor()-6)%5;
const int col2 = 7+(room::getColor()-5)%5;
const int col3 = 7+(room::getColor()-4)%5;
const int col1 = room::getColor(1);
const int col2 = room::getColor(2);
const int col3 = room::getColor(3);
draw::print2("a", 4, 26, col1, FONT_ZOOM_NONE);
draw::print2("b", 7, 26, col2, FONT_ZOOM_NONE);
draw::print2("c", 10, 26, col3, FONT_ZOOM_NONE);
@@ -385,13 +385,13 @@ bool game::loop()
draw::print2(actor::hero::getBoostRun()/2, 2, 9, 27, col2, FONT_ZOOM_NONE);
draw::setSource(draw::getSurface("objectes.gif"));
draw::swapcol(1, actor::hero::getSkills()&SKILL_SHOES ? WHITE : BLUE);
draw::swapcol(1, actor::hero::getSkills()&SKILL_SHOES ? col1 : col3);
draw::draw(276,166, 28, 22, 162, 0);
draw::swapcol(1, actor::hero::getSkills()&SKILL_PANTS ? WHITE : BLUE);
draw::swapcol(1, actor::hero::getSkills()&SKILL_PANTS ? col1 : col3);
draw::draw(250,183, 18, 23, 167, 22);
draw::swapcol(1, actor::hero::getSkills()&SKILL_GLOVES ? WHITE : BLUE);
draw::swapcol(1, actor::hero::getSkills()&SKILL_GLOVES ? col1 : col3);
draw::draw(222,200, 21, 22, 165, 45);
draw::swapcol(1, actor::hero::getSkills()&SKILL_BAG ? WHITE : BLUE);
draw::swapcol(1, actor::hero::getSkills()&SKILL_BAG ? col1 : col3);
draw::draw(279,200, 20, 25, 145, 41);
/*
print(0,0,input::mouseX());
@@ -586,7 +586,7 @@ switch (section)
ui::label("TEXTURES", 2, line, 96, 11, GRAY); line+=10;
changed |= btn_opt("COLOR", 2, line, room::editor::refColor(), {7, 8, 9, 10, 11}, {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"}, 47); //ui::label("COLOR", 2, line, 64, 11);
changed |= btn_opt("COLOR", 2, line, room::editor::refColor(), {0, 1, 2, 3, 4}, {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"}, 47); //ui::label("COLOR", 2, line, 64, 11);
//changed |= btn_small(64, line, room::editor::refColor(), 5, 11);
line += 10;
ui::label("FLOOR", 2, line, 48, 11);

View File

@@ -20,8 +20,8 @@ namespace room
static int doors = NO_DOOR; // Portes obertes
static int door_height[4]; // Altura de cada porta
static int exits[6]; // Habitació destí a la que du cada porta (piso i sostre inclosos)
static int color = 5; // Color de l'habitació
static int exits[6]; // Habitació destí a la que du cada porta (piso i sostre inclosos)
static int color = 0; // Esquema de color de l'habitació
static int floor_type = 0; // Tile per al piso
static int walls_type = 0; // Tile per a les pareds
@@ -36,6 +36,14 @@ namespace room
static draw::surface *doors_surf = nullptr;
static draw::surface *aux_surf = nullptr;
static uint8_t color_schemes[5][4] = {
{7, 11, 10, 9},
{8, 11, 9, 7},
{9, 11, 10, 8},
{10, 11, 8, 7},
{11, 10, 9, 8},
};
void init()
{
actor::clear();
@@ -141,7 +149,7 @@ namespace room
door_height[YN] = SDL_clamp(val, -1, 5);
} else if (util::strcomp(key, "color:")) {
color = util::stringToInt(file::readString(&buffer), {"purple", "green", "cyan", "yellow", "white"}, {7, 8, 9, 10, 11});
color = util::stringToInt(file::readString(&buffer), {"purple", "green", "cyan", "yellow", "white"}, {0, 1, 2, 3, 4});
} else if (util::strcomp(key, "floor-texture:")) {
floor_type = file::readInt(&buffer);
@@ -209,7 +217,7 @@ namespace room
void draw()
{
draw::pushSource();
draw::swapcol(1, color);
draw::swapcol(1, color_schemes[color][0]);
const int floor_row_tiles = int(floor_surf->w/32);
const int floor_x = (floor_type%floor_row_tiles)*32;
@@ -306,7 +314,7 @@ namespace room
void draw2()
{
draw::pushSource();
draw::swapcol(1, color);
draw::swapcol(1, color_schemes[color][0]);
const int doors_row_tiles = int(doors_surf->w/40);
const int doors_x = (doors_type%doors_row_tiles)*40;
@@ -383,9 +391,9 @@ namespace room
return exits[d];
}
int getColor()
int getColor(int which)
{
return color;
return color_schemes[color][which];
}
int getFloorCount()
@@ -440,7 +448,7 @@ namespace room
const char *numToColor(uint8_t value)
{
const char* colors[5] = {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"};
return colors[value-7];
return colors[value];
}
void modify() { modified = true; }

View File

@@ -30,7 +30,7 @@ namespace room
int getDoors();
int getDoor(const int d);
int getExit(const int d);
int getColor();
int getColor(int which);
int getFloorCount();
int getDoorCount();