Acabat el nou motor per a textos en pantalla
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
#include "path_sprite.h"
|
||||
#include <bits/std_abs.h> // Para abs
|
||||
#include <stdlib.h> // Para abs
|
||||
#include <utility> // Para move
|
||||
#include "moving_sprite.h" // Para MovingSprite
|
||||
#include "utils.h" // Para easeOutQuint
|
||||
#include <functional>
|
||||
class Texture; // lines 3-3
|
||||
#include <bits/std_abs.h> // for abs
|
||||
#include <stdlib.h> // for abs
|
||||
#include <functional> // for function
|
||||
#include <utility> // for move
|
||||
|
||||
// Devuelve un vector con los puntos que conforman la ruta
|
||||
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction)
|
||||
@@ -54,9 +51,34 @@ void PathSprite::update()
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
void PathSprite::addPath(Path path)
|
||||
void PathSprite::addPath(Path path, bool centered)
|
||||
{
|
||||
paths_.emplace_back(path);
|
||||
PathCentered path_centered = PathCentered::NONE;
|
||||
if (centered)
|
||||
path_centered = (path.spots.back().x == path.spots.front().x) ? PathCentered::ON_X : PathCentered::ON_Y;
|
||||
|
||||
switch (path_centered)
|
||||
{
|
||||
case PathCentered::ON_X:
|
||||
{
|
||||
const int x = path.spots.back().x - pos_.w / 2;
|
||||
for (auto &spot : path.spots)
|
||||
spot.x = x;
|
||||
paths_.emplace_back(path);
|
||||
break;
|
||||
}
|
||||
case PathCentered::ON_Y:
|
||||
{
|
||||
const int y = path.spots.back().y - pos_.h / 2;
|
||||
for (auto &spot : path.spots)
|
||||
spot.y = y;
|
||||
paths_.emplace_back(path);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
paths_.emplace_back(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
@@ -103,7 +125,7 @@ void PathSprite::moveThroughCurrentPath()
|
||||
if (path.waiting_counter == 0)
|
||||
path.finished = true;
|
||||
else
|
||||
--path.waiting_counter;
|
||||
--path.waiting_counter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user