Empezando a trabajar con los enemigos

This commit is contained in:
2022-08-20 19:11:59 +02:00
parent bb5d772a4b
commit 82089bb780
13 changed files with 68 additions and 14 deletions

View File

@@ -0,0 +1,10 @@
png_width_in_tiles=6
tile_width=16
tile_height=16
[animation]
name=walk
speed=8
loop=yes
frames=0,1,2,3,4,5,6
[/animation]

BIN
data/actors/enemies/bug.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,10 @@
png_width_in_tiles=6
tile_width=16
tile_height=16
[animation]
name=walk
speed=8
loop=yes
frames=0,1,2,3,4,5,6
[/animation]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,10 @@
png_width_in_tiles=6
tile_width=16
tile_height=16
[animation]
name=walk
speed=8
loop=yes
frames=0,1,2,3,4,5,6
[/animation]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,10 @@
png_width_in_tiles=6
tile_width=16
tile_height=16
[animation]
name=walk
speed=8
loop=yes
frames=0,1,2,3,4,5,6
[/animation]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -132,11 +132,7 @@ bool Map::setVars(std::string var, std::string value)
// Indicador de éxito en la asignación // Indicador de éxito en la asignación
bool success = true; bool success = true;
if (var == "bg_img") if (var == "tileset_img")
{
bg_img = value;
}
else if (var == "tileset_img")
{ {
tileset_img = value; tileset_img = value;
} }
@@ -176,10 +172,18 @@ void Map::fillMapTexture()
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
// Dibuja el degradado de fondo // Dibuja el degradado de fondo
for (int i = 0; i < 208; i++) const int num_lines = 208;
const color_t color1 = {234, 171, 159};
const color_t color2 = {144, 225, 231};
for (int i = 0; i < num_lines; i++)
{ {
SDL_SetRenderDrawColor(renderer, 234, 171, 159, 0xFF); float step = ((float)i / (float)num_lines);
SDL_SetRenderDrawColor(renderer, 144, 225, 231, 0xFF); int r = color1.r + ((color2.r - color1.r) * step);
int g = color1.g + ((color2.g - color1.g) * step);
int b = color1.b + ((color2.b - color1.b) * step);
SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
SDL_RenderDrawLine(renderer, 0, i, 320, i); SDL_RenderDrawLine(renderer, 0, i, 320, i);
} }
@@ -205,6 +209,7 @@ void Map::fillMapTexture()
// Dibuja el marco del marcador // Dibuja el marco del marcador
SDL_SetRenderDrawColor(renderer, 85, 50, 85, 0xFF); SDL_SetRenderDrawColor(renderer, 85, 50, 85, 0xFF);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
SDL_Rect rect = {0, 208, 320, 32}; SDL_Rect rect = {0, 208, 320, 32};
SDL_RenderDrawRect(renderer, &rect); SDL_RenderDrawRect(renderer, &rect);
rect = {1, 209, 318, 30}; rect = {1, 209, 318, 30};

View File

@@ -39,7 +39,6 @@ private:
std::string room_left; // Identificador de la habitación que se encuentra a la izquierda std::string room_left; // Identificador de la habitación que se encuentra a la izquierda
std::string room_right; // Identificador de la habitación que se encuentra a la derecha std::string room_right; // Identificador de la habitación que se encuentra a la derecha
std::string tileset_img; // Imagen con los graficos para la habitación std::string tileset_img; // Imagen con los graficos para la habitación
std::string bg_img; // Imagen con los graficos para la habitación
std::vector<int> tilemap; // Indice de los tiles a dibujar en la habitación std::vector<int> tilemap; // Indice de los tiles a dibujar en la habitación
LTexture *texture_tile; // Textura con los graficos de los tiles habitación LTexture *texture_tile; // Textura con los graficos de los tiles habitación
SDL_Texture *map_texture; // Textura para dibujar el mapa de la habitación SDL_Texture *map_texture; // Textura para dibujar el mapa de la habitación

View File

@@ -82,12 +82,12 @@ void Player::checkInput()
if (input->checkInput(INPUT_LEFT, REPEAT_TRUE)) if (input->checkInput(INPUT_LEFT, REPEAT_TRUE))
{ {
vx = std::max(vx -= accelX, -maxVX); vx = std::max(vx -= accelX, -maxVX);
sprite->setFlip(SDL_FLIP_NONE); sprite->setFlip(SDL_FLIP_HORIZONTAL);
} }
else if (input->checkInput(INPUT_RIGHT, REPEAT_TRUE)) else if (input->checkInput(INPUT_RIGHT, REPEAT_TRUE))
{ {
vx = std::min(vx += accelX, maxVX); vx = std::min(vx += accelX, maxVX);
sprite->setFlip(SDL_FLIP_HORIZONTAL); sprite->setFlip(SDL_FLIP_NONE);
} }
else else
{ {

View File

@@ -172,6 +172,16 @@ bool Prog::setFileList()
asset->add("/data/font/debug.png", font); asset->add("/data/font/debug.png", font);
asset->add("/data/font/debug.txt", font); asset->add("/data/font/debug.txt", font);
// Ficheros de enemigos
asset->add("/data/actors/enemies/walking_eye.png", bitmap);
asset->add("/data/actors/enemies/walking_eye.ani", data);
asset->add("/data/actors/enemies/bug.png", bitmap);
asset->add("/data/actors/enemies/bug.ani", data);
asset->add("/data/actors/enemies/flying_eye.png", bitmap);
asset->add("/data/actors/enemies/flying_eye.ani", data);
asset->add("/data/actors/enemies/flying_eye_horn.png", bitmap);
asset->add("/data/actors/enemies/flying_eye_horn.ani", data);
return asset->check(); return asset->check();
} }