This commit is contained in:
2022-08-28 11:36:45 +02:00
16 changed files with 153 additions and 82 deletions

View File

@@ -3,7 +3,7 @@ frame_width=16
frame_height=16
[animation]
name=walk
name=default
speed=8
loop=0
frames=0,1,2,3,4,5

View File

@@ -3,7 +3,7 @@ frame_width=16
frame_height=16
[animation]
name=walk
name=default
speed=8
loop=0
frames=0,1,2,3,4,5

View File

@@ -3,7 +3,7 @@ frame_width=16
frame_height=16
[animation]
name=walk
name=default
speed=6
loop=0
frames=0,1,2,3,4,5

View File

@@ -3,7 +3,7 @@ frame_width=16
frame_height=16
[animation]
name=walk
name=default
speed=8
loop=0
frames=0,1,2,3,4,5

View File

@@ -5,30 +5,30 @@
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,140,0,0,0,0,0,0,27,28,29,30,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,173,174,0,0,0,0,0,0,61,62,63,64,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,140,0,0,0,0,0,0,0,0,0,0,0,0,95,96,97,98,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,173,174,0,0,0,0,0,0,0,0,0,0,0,0,129,130,131,132,0,0,0,0,0,0,
0,139,140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,173,174,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,140,0,0,
0,0,0,0,0,0,0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0,0,0,0,0,111,112,45,46,7,8,0,0,0,5,6,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,0,0,0,0,0,0,0,0,0,0,37,38,41,42,0,0,0,39,40,0,0,0,0,0,0,
344,345,0,0,0,0,0,207,208,0,0,0,0,41,42,0,0,0,0,0,0,0,343,344,292,293,294,344,345,0,0,0,105,106,0,0,0,0,0,0,
378,379,0,0,0,0,0,241,242,0,0,0,0,37,38,0,0,343,291,344,291,291,313,314,326,327,328,378,379,0,0,0,37,38,0,0,0,0,0,0,
279,280,291,292,279,280,279,291,292,280,279,280,291,292,279,280,279,280,281,281,282,281,282,281,281,282,281,282,279,280,279,280,291,292,279,280,291,292,279,280,
313,314,325,326,313,314,313,325,326,314,313,314,325,326,313,314,313,314,313,315,316,314,313,314,313,314,313,314,313,314,313,314,325,326,313,314,325,326,313,314
0,0,0,0,0,0,0,0,0,0,0,0,583,584,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,239,240,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,69,70,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,366,367,367,368,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,0,101,102,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,430,431,431,432,0,0,0,0,577,578,579,580,581,582,0,0,0,0,0,0,0,0,583,584,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,615,616,69,70,0,0,0,93,94,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,189,190,0,0,0,0,0,0,0,0,0,0,189,190,101,102,0,0,0,125,126,0,0,0,0,0,0,
363,364,0,0,0,0,0,193,194,0,0,0,0,189,190,0,0,0,0,0,0,0,362,282,277,278,279,274,364,0,0,0,157,158,0,0,0,0,0,0,
295,396,0,0,0,0,0,225,226,0,0,0,0,189,190,0,0,362,275,275,275,275,313,314,309,310,311,312,396,0,0,0,189,190,0,0,0,0,0,0,
265,264,263,264,263,264,263,264,263,264,263,264,263,264,263,264,263,264,263,266,266,266,283,284,266,265,266,264,263,264,263,264,263,264,263,264,263,264,263,264,
295,296,295,296,295,296,295,296,295,265,295,296,295,296,295,296,295,296,295,296,295,296,315,316,298,297,298,296,295,296,295,296,295,296,295,296,295,296,295,296
</data>
</layer>
</map>

View File

@@ -12,3 +12,18 @@ y1=12
x2=9
y2=20
[/path]
[path]
tileset=flying_eye_horn.png
animation=flying_eye_horn.ani
width=16
height=16
x=15
y=5
vx=0.5
vy=0
x1=5
y1=5
x2=30
y2=5
[/path]

44
data/map/03.ene Normal file
View File

@@ -0,0 +1,44 @@
[path]
tileset=walking_eye.png
animation=walking_eye.ani
width=16
height=16
x=13
y=23
vx=0.4
vy=0
x1=3
y1=23
x2=18
y2=23
[/path]
[path]
tileset=walking_eye.png
animation=walking_eye.ani
width=16
height=16
x=22
y=13
vx=0.4
vy=0
x1=20
y1=13
x2=24
y2=13
[/path]
[path]
tileset=walking_eye.png
animation=walking_eye.ani
width=16
height=16
x=27
y=8
vx=-0.4
vy=0
x1=25
y1=8
x2=29
y2=8
[/path]

View File

@@ -1,4 +1,5 @@
tileset_img=surface.png
enemy_file=03.ene
bgColor1=143,86,59
bgColor2=69,40,60
@@ -31,4 +32,13 @@ x=22
y=12
[/diamond]
[diamond]
tileset=diamond.png
animation=diamond.ani
width=16
height=16
x=2
y=22
[/diamond]
[/actors]

View File

@@ -28,15 +28,21 @@ AnimatedSprite::~AnimatedSprite()
// Obtiene el indice de la animación a partir del nombre
int AnimatedSprite::getIndex(std::string name)
{
int result = -1;
int index = -1;
for (int i = 0; i < animation.size(); i++)
{
if (animation[i].name == name)
{
result = i;
index = i;
}
}
return result;
if (index == -1)
{
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
index = 0;
}
return index;
}
// Calcula el frame correspondiente a la animación

View File

@@ -22,8 +22,6 @@ EnemyEngine::~EnemyEngine()
delete enemy;
}
enemies.clear();
delete enemy;
}
// Pinta los enemigos en pantalla
@@ -33,7 +31,6 @@ void EnemyEngine::render()
{
enemy->render();
}
enemy->render();
}
// Actualiza las variables del objeto
@@ -43,7 +40,6 @@ void EnemyEngine::update()
{
enemy->update();
}
enemy->update();
}
// Carga las variables desde un fichero
@@ -88,8 +84,7 @@ bool EnemyEngine::load(std::string file_path)
} while (line != "[/path]");
printf("** enemy path loaded\n\n");
//enemies.push_back(new EnemyPath(enemy, p1, p2));
enemy = new EnemyPath(enemy, p1, p2);
enemies.push_back(new EnemyPath(enemy, p1, p2));
}
}
@@ -173,19 +168,3 @@ bool EnemyEngine::setEnemy(enemy_t *enemy, SDL_Point *p1, SDL_Point *p2, std::st
return success;
}
// Carga el vector de enemigos
//bool EnemyEngine::setEnemies(std::string file)
//{
// // Elimina todos los enemigos anteriores
// for (auto enemy : enemies)
// {
// delete enemy;
// }
// enemies.clear();
//
// // Carga el vector de enemigos desde un fichero
// const bool success = load(file);
//
// return success;
//}

View File

@@ -22,7 +22,6 @@ private:
Map *map; // Mapa con la información de la habitación
Player *player; // Puntero con el jugador
std::vector<EnemyPath *> enemies; // Vector con la lista de enemigos
EnemyPath *enemy;
// Carga las variables desde un fichero
bool load(std::string file_path);
@@ -42,9 +41,6 @@ public:
// Actualiza las variables del objeto
void update();
// Carga el vector de enemigos
//bool setEnemies(std::string file);
};
#endif

View File

@@ -27,7 +27,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
section.subsection = SUBSECTION_GAME_PLAY;
musicEnabled = true;
debug = true;
debug = false;
musicEnabled = !debug;
}
@@ -219,25 +219,16 @@ bool Game::changeMap(std::string file)
{ // Verifica que exista el fichero que se va a cargar
if (asset->get(file) != "")
{
// Elimina la habitación actual
// Elimina la habitación actual y crea un objeto nuevo a partir del fichero
delete map;
// Crea un objeto habitación nuevo a partir del fichero
map = new Map(asset->get(file), renderer, asset, itemTracker);
// Elimina el gestor de enemigos y crea uno nuevo a partir de un fichero
delete enemyEngine;
enemyEngine = new EnemyEngine(renderer, asset, player, map, asset->get(map->getEnemyFile()));
success = true;
}
// Carga los enemigos
// const std::string enemyFile = asset->get(map->getEnemyFile());
// if (enemyFile != "")
//{
// enemyEngine->setEnemies(enemyFile);
// success = true;
//}
}
return success;

View File

@@ -219,7 +219,6 @@ void Player::move()
vx = 0.0f;
}
// Mueve en el eje Y y comprueba colisiones con muros
y += vy;
if (checkMapCollisions())
@@ -238,8 +237,8 @@ void Player::move()
vy = 0.0f;
}
// Si no hay colisiones con los muros en el eje Y, comprueba no haya atravesado
// el suelo de un tile atravesble
// Si no hay colisiones con los muros en el eje Y, comprueba
// no haya atravesado el suelo de un tile atravesble
else
{
const int a = (lastPosition.y + h) / tileSize;
@@ -265,14 +264,20 @@ void Player::move()
}
}
const bool going_down2 = vy >= 0.0f;
const bool tile_aligned2 = ((int)y + h) % tileSize == 0;
// Si está cayendo
if (vy >= 0.0f)
if (going_down2)
{
state = falling;
if (isOnFloor())
// Si está alineado con el tile mira el suelo (para que no lo mire si está
// dentro de un tile atravesable y lo deje a medias)
if (tile_aligned2)
{
state = standing;
if (isOnFloor())
{
state = standing;
}
}
// Si no esta enganchado a una plataforma

View File

@@ -26,7 +26,7 @@ Prog::Prog(std::string executablePath)
}
else
{
section.name = SECTION_PROG_GAME;
section.name = SECTION_PROG_LOGO;
}
input = new Input(asset->get("gamecontrollerdb.txt"));
screen = new Screen(window, renderer, options);
@@ -146,6 +146,7 @@ bool Prog::setFileList()
asset->add("/data/map/02.ene", data);
asset->add("/data/map/03.map", data);
asset->add("/data/map/03.tmx", data);
asset->add("/data/map/03.ene", data);
asset->add("/data/map/surface.png", bitmap);
// Ficheros de configuración

View File

@@ -64,7 +64,7 @@ void Title::initMenu()
menu->loadAudioFile(asset->get("sound_menu_move.wav"), SOUND_MOVE);
menu->init("TITLE", 0, 150, MENU_BACKGROUND_TRANSPARENT);
menu->addItem("START",2);
menu->addItem("START", 2);
menu->addItem("OPTIONS", 5);
menu->addItem("EXIT");
menu->setDefaultActionWhenCancel(2);
@@ -103,6 +103,7 @@ void Title::update()
}
sprite->animate();
menu->update();
checkMenu();
}
}
@@ -117,7 +118,7 @@ void Title::render()
// Dibuja los objetos
sprite->render();
text2->writeDX(TXT_CENTER | TXT_COLOR, 160, 205, "@2016,2022 JAILDESIGNER & JAILBROTHER (v0.6)", 0, {255, 93, 4});
text2->writeDX(TXT_CENTER | TXT_COLOR, 160, 205, "@2016,2022 JAILDESIGNER & JAILBROTHER (v0.4)", 0, {255, 93, 4});
menu->render();
// Vuelca el contenido del renderizador en pantalla
@@ -139,3 +140,23 @@ section_t Title::run()
JA_StopMusic();
}
// Comprueba el menu
void Title::checkMenu()
{
const int menu = this->menu->getItemSelected();
switch (menu)
{
case 0:
section.name = SECTION_PROG_GAME;
break;
case 2:
section.name = SECTION_PROG_QUIT;
break;
default:
break;
}
}

View File

@@ -42,6 +42,9 @@ private:
// Crea el menu
void initMenu();
// Comprueba el menu
void checkMenu();
public:
// Constructor
Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input);