forked from jaildesigner-jailgames/jaildoctors_dilemma
Los items ya brillan a distinto ritmo
This commit is contained in:
@@ -47,6 +47,7 @@ tileset=items.png
|
||||
tile=0
|
||||
x=1
|
||||
y=7
|
||||
counter=6
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
@@ -54,4 +55,47 @@ tileset=items.png
|
||||
tile=0
|
||||
x=17
|
||||
y=8
|
||||
counter=7
|
||||
[/item]
|
||||
|
||||
|
||||
|
||||
[item]
|
||||
tileset=items.png
|
||||
tile=0
|
||||
x=12
|
||||
y=12
|
||||
counter=1
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
tileset=items.png
|
||||
tile=0
|
||||
x=13
|
||||
y=12
|
||||
counter=2
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
tileset=items.png
|
||||
tile=0
|
||||
x=14
|
||||
y=12
|
||||
counter=3
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
tileset=items.png
|
||||
tile=0
|
||||
x=15
|
||||
y=12
|
||||
counter=4
|
||||
[/item]
|
||||
|
||||
[item]
|
||||
tileset=items.png
|
||||
tile=0
|
||||
x=16
|
||||
y=12
|
||||
counter=5
|
||||
[/item]
|
||||
@@ -182,22 +182,23 @@ void Game::renderDebugInfo()
|
||||
|
||||
// Pinta el texto
|
||||
std::string text;
|
||||
int line = (16 * 8) + 3;
|
||||
const int inc = debugText->getCharacterWidth() + 1;
|
||||
int line = 131;
|
||||
|
||||
text = "status: " + std::to_string(player->status);
|
||||
debugText->write(0, line += 6, text);
|
||||
debugText->write(0, line += inc, text);
|
||||
|
||||
text = "foot: " + std::to_string((int)player->getLeftFoot().y);
|
||||
debugText->write(0, line += 6, text);
|
||||
debugText->write(0, line += inc, text);
|
||||
|
||||
const int a = (player->lastPosition.y + 16) / 8;
|
||||
const int b = player->getLeftFoot().y / 8;
|
||||
text = "tile: " + std::to_string(a) + " - " + std::to_string(b);
|
||||
debugText->write(0, line += 6, text);
|
||||
debugText->write(0, line += inc, text);
|
||||
|
||||
const bool collision = checkPlayerAndEnemies();
|
||||
text = "collision: " + std::to_string(collision);
|
||||
debugText->write(0, line += 6, text);
|
||||
debugText->write(0, line += inc, text);
|
||||
}
|
||||
|
||||
// Cambia de habitación
|
||||
|
||||
@@ -19,6 +19,8 @@ Item::Item(item_t item)
|
||||
// Inicia variables
|
||||
sprite->setSpriteClip(item.tile * 8, 0, 8, 8);
|
||||
collider = sprite->getRect();
|
||||
colorChangeSpeed = 4;
|
||||
counter = item.counter * colorChangeSpeed;
|
||||
|
||||
// Inicializa los colores
|
||||
color_t c = stringToColor("blue");
|
||||
@@ -54,7 +56,7 @@ Item::~Item()
|
||||
// Pinta el objeto en pantalla
|
||||
void Item::render()
|
||||
{
|
||||
const int index = (counter / 2) % color.size();
|
||||
const int index = (counter / colorChangeSpeed) % color.size();
|
||||
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
|
||||
sprite->render();
|
||||
sprite->getTexture()->setColor(255, 255, 255);
|
||||
|
||||
@@ -22,23 +22,21 @@ struct item_t
|
||||
int x; // Posicion del item en pantalla
|
||||
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
|
||||
};
|
||||
|
||||
// Clase Item
|
||||
class Item
|
||||
{
|
||||
private:
|
||||
LTexture *texture; // Textura con los graficos del objeto
|
||||
Sprite *sprite; // Sprite del objeto
|
||||
|
||||
LTexture *texture; // Textura con los graficos del objeto
|
||||
Sprite *sprite; // Sprite del objeto
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||
std::vector<color_t> color; // Vector con los colores del objeto
|
||||
int counter; // Contador interno
|
||||
SDL_Rect collider; // Rectangulo de colisión
|
||||
|
||||
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
||||
void checkPath();
|
||||
int colorChangeSpeed; // Cuanto mas alto, mas tarda en cambiar de color
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
|
||||
@@ -149,6 +149,7 @@ bool Room::load(std::string _file_path)
|
||||
item_t item;
|
||||
item.asset = asset;
|
||||
item.renderer = renderer;
|
||||
item.counter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -265,71 +266,71 @@ bool Room::setEnemy(enemy_t *enemy, std::string var, std::string value)
|
||||
{
|
||||
enemy->tileset = value;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "animation")
|
||||
{
|
||||
enemy->animation = value;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "width")
|
||||
{
|
||||
enemy->w = std::stof(value);
|
||||
}
|
||||
|
||||
|
||||
else if (var == "height")
|
||||
{
|
||||
enemy->h = std::stof(value);
|
||||
}
|
||||
|
||||
|
||||
else if (var == "x")
|
||||
{
|
||||
enemy->x = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "y")
|
||||
{
|
||||
enemy->y = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "vx")
|
||||
{
|
||||
enemy->vx = std::stof(value);
|
||||
}
|
||||
|
||||
|
||||
else if (var == "vy")
|
||||
{
|
||||
enemy->vy = std::stof(value);
|
||||
}
|
||||
|
||||
|
||||
else if (var == "x1")
|
||||
{
|
||||
enemy->x1 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "x2")
|
||||
{
|
||||
enemy->x2 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "y1")
|
||||
{
|
||||
enemy->y1 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "y2")
|
||||
{
|
||||
enemy->y2 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "color")
|
||||
{
|
||||
enemy->color = stringToColor(value);
|
||||
}
|
||||
|
||||
|
||||
else if (var == "[/enemy]")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
@@ -348,26 +349,31 @@ bool Room::setItem(item_t *item, std::string var, std::string value)
|
||||
{
|
||||
item->tileset = value;
|
||||
}
|
||||
|
||||
|
||||
if (var == "counter")
|
||||
{
|
||||
item->counter = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "x")
|
||||
{
|
||||
item->x = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "y")
|
||||
{
|
||||
item->y = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
|
||||
else if (var == "tile")
|
||||
{
|
||||
item->tile = std::stof(value);
|
||||
}
|
||||
|
||||
|
||||
else if (var == "[/item]")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
|
||||
12
todo.md
12
todo.md
@@ -11,14 +11,14 @@
|
||||
(A) Crear tiles que deslicen, (no tipo hielo sino cinta)
|
||||
(A) Tiles animados
|
||||
(A) Crear ascensores
|
||||
(A) Enemigos de diferente tamaño
|
||||
(A) Enemigos de diferente tamaño {cm:2022-08-30}
|
||||
(A) Color de los items al estilo jet set willy de amstrad, que brillan con dos colores
|
||||
(A) Temporizador de inicio de los items, para poder hacer que brillen a distinto ritmo. Esto es incompatible con lo anterior
|
||||
(A) Temporizador de inicio de los items, para poder hacer que brillen a distinto ritmo. Esto es incompatible con lo anterior {cm:2022-08-30}
|
||||
|
||||
(A) Poner la info de debug con la tipografia adecuada
|
||||
(A) El modo debug debe pintar la rejilla
|
||||
(A) Tecla F para pasar a pantalla completa
|
||||
(A) Tecla + y - para cambiar tamaño de ventana. O control F1 a F4
|
||||
(A) Poner la info de debug con la tipografia adecuada {cm:2022-08-30}
|
||||
(A) El modo debug debe pintar la rejilla {cm:2022-08-30}
|
||||
(A) Tecla F para pasar a pantalla completa {cm:2022-08-30}
|
||||
(A) Tecla + y - para cambiar tamaño de ventana. O control F1 a F4 {cm:2022-08-30}
|
||||
|
||||
|
||||
## TEMAS
|
||||
|
||||
Reference in New Issue
Block a user