Creando contenido. Los items ya pillan el color desde el archivo de mapa

This commit is contained in:
2022-09-20 20:45:08 +02:00
parent 13046d5dcf
commit e7cc5b49ea
23 changed files with 514 additions and 177 deletions

View File

@@ -490,6 +490,8 @@ bool Director::setFileList()
asset->add("/data/enemies/chip.ani", data);
asset->add("/data/enemies/wave.png", bitmap);
asset->add("/data/enemies/wave.ani", data);
asset->add("/data/enemies/wave_v.png", bitmap);
asset->add("/data/enemies/wave_v.ani", data);
asset->add("/data/enemies/sigmasua.png", bitmap);
asset->add("/data/enemies/sigmasua.ani", data);
asset->add("/data/enemies/diskette.png", bitmap);

View File

@@ -24,8 +24,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
//currentRoom = "06.room";
//spawnPoint = {14 * 8, 9 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
currentRoom = "03.room";
const int x = 26;
currentRoom = "60.room";
const int x = 16;
const int y = 13;
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
// ****

View File

@@ -16,11 +16,16 @@ Item::Item(item_t item)
// Inicia variables
sprite->setSpriteClip((item.tile % 10) * 8, (item.tile / 10) * 8, 8, 8);
collider = sprite->getRect();
colorChangeSpeed = 4;
colorChangeSpeed = 8;
counter = item.counter * colorChangeSpeed;
// Inicializa los colores
color_t c = stringToColor("blue");
color_t c = item.color1;
color.push_back(c);
c = item.color2;
color.push_back(c);
/*color_t c = stringToColor("blue");
color.push_back(c);
c = stringToColor("red");
@@ -36,7 +41,7 @@ Item::Item(item_t item)
color.push_back(c);
c = stringToColor("yellow");
color.push_back(c);
color.push_back(c);*/
}
// Destructor

View File

@@ -23,6 +23,8 @@ struct item_t
int y; // Posicion del item en pantalla
int tile; // Numero de tile dentro de la textura
int counter; // Contador inicial. Es el que lo hace cambiar de color
color_t color1;
color_t color2;
};
// Clase Item

View File

@@ -12,6 +12,8 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset
mapHeight = 16;
tilesetWidth = 20;
paused = false;
itemColor1 = stringToColor("magenta");
itemColor2 = stringToColor("yellow");
// Copia los punteros a objetos
this->renderer = renderer;
@@ -166,6 +168,8 @@ bool Room::load(std::string file_path)
item.asset = asset;
item.renderer = renderer;
item.counter = 0;
item.color1 = itemColor1;
item.color2 = itemColor2;
do
{
@@ -238,6 +242,16 @@ bool Room::setVars(std::string var, std::string value)
borderColor = stringToColor(value);
}
else if (var == "itemColor1")
{
itemColor1 = stringToColor(value);
}
else if (var == "itemColor2")
{
itemColor2 = stringToColor(value);
}
else if (var == "tileset")
{
tileset = value;
@@ -571,17 +585,17 @@ void Room::renderItems()
void Room::update()
{
if (paused)
{//Si está en modo pausa no se actualiza nada
{ // Si está en modo pausa no se actualiza nada
return;
}
for (auto enemy : enemies)
{// Actualiza los enemigos
{ // Actualiza los enemigos
enemy->update();
}
for (auto item : items)
{// Actualiza los items
{ // Actualiza los items
item->update();
}
}

View File

@@ -46,6 +46,8 @@ private:
std::string name; // Nombre de la habitación
color_t bgColor; // Color de fondo de la habitación
color_t borderColor; // Color de fondo de la habitación
color_t itemColor1;
color_t itemColor2;
std::string roomUp; // Identificador de la habitación que se encuentra arriba
std::string roomDown; // Identificador de la habitación que se encuentra abajp
std::string roomLeft; // Identificador de la habitación que se encuentra a la izquierda