Trabajando en los frames iniciales aleatorios de los enemigos
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=3
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=5
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=8
|
frame_height=8
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=2
|
|
||||||
frame_width=13
|
frame_width=13
|
||||||
frame_height=15
|
frame_height=15
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=2
|
|
||||||
frame_width=11
|
frame_width=11
|
||||||
frame_height=13
|
frame_height=13
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=6
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=6
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=6
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=8
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=16
|
frame_width=16
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=8
|
frame_height=8
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=6
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=8
|
frame_height=8
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=4
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
frames_per_row=8
|
|
||||||
frame_width=8
|
frame_width=8
|
||||||
frame_height=16
|
frame_height=16
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,7 @@ AnimatedSprite::~AnimatedSprite()
|
|||||||
int AnimatedSprite::getIndex(std::string name)
|
int AnimatedSprite::getIndex(std::string name)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = -1;
|
||||||
/*for (int i = 0; i < (int)animation.size(); i++)
|
|
||||||
{
|
|
||||||
if (animation[i].name == name)
|
|
||||||
{
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
for (auto a : animation)
|
for (auto a : animation)
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
@@ -46,7 +40,6 @@ int AnimatedSprite::getIndex(std::string name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
|
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
|
||||||
index = 0;
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -230,17 +223,23 @@ bool AnimatedSprite::load(std::string filePath)
|
|||||||
{
|
{
|
||||||
frames_per_row = std::stoi(line.substr(pos + 1, line.length()));
|
frames_per_row = std::stoi(line.substr(pos + 1, line.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frame_width")
|
else if (line.substr(0, pos) == "frame_width")
|
||||||
{
|
{
|
||||||
frame_width = std::stoi(line.substr(pos + 1, line.length()));
|
frame_width = std::stoi(line.substr(pos + 1, line.length()));
|
||||||
|
|
||||||
|
// Normaliza valores
|
||||||
|
if (frames_per_row == 0)
|
||||||
|
{
|
||||||
|
frames_per_row = texture->getWidth() / frame_width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frame_height")
|
else if (line.substr(0, pos) == "frame_height")
|
||||||
{
|
{
|
||||||
frame_height = std::stoi(line.substr(pos + 1, line.length()));
|
frame_height = std::stoi(line.substr(pos + 1, line.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
|
||||||
@@ -261,12 +260,6 @@ bool AnimatedSprite::load(std::string filePath)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normaliza valores
|
|
||||||
if (frames_per_row == 0)
|
|
||||||
{
|
|
||||||
frames_per_row = texture->getWidth() / frame_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pone un valor por defecto
|
// Pone un valor por defecto
|
||||||
setPos({0, 0, frame_width, frame_height});
|
setPos({0, 0, frame_width, frame_height});
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ Enemy::Enemy(enemy_t enemy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
collider = getRect();
|
collider = getRect();
|
||||||
|
|
||||||
|
// Coloca un frame al azar
|
||||||
|
sprite->setCurrentFrame(rand() % 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -56,7 +59,6 @@ void Enemy::render()
|
|||||||
void Enemy::update()
|
void Enemy::update()
|
||||||
{
|
{
|
||||||
sprite->update();
|
sprite->update();
|
||||||
// sprite->animate();
|
|
||||||
checkPath();
|
checkPath();
|
||||||
collider = getRect();
|
collider = getRect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ int main(int argc, char *args[])
|
|||||||
printf("Starting the game...\n\n");
|
printf("Starting the game...\n\n");
|
||||||
|
|
||||||
// Crea el objeto Director
|
// Crea el objeto Director
|
||||||
Director *mDirector = new Director(args[0]);
|
Director *director = new Director(args[0]);
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
mDirector->run();
|
director->run();
|
||||||
|
|
||||||
// Destruye el objeto Director
|
// Destruye el objeto Director
|
||||||
delete mDirector;
|
delete director;
|
||||||
mDirector = nullptr;
|
director = nullptr;
|
||||||
|
|
||||||
printf("\nShutting down the game...\n");
|
printf("\nShutting down the game...\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user