commit de me ane cap a casa
This commit is contained in:
@@ -16,34 +16,46 @@ void PathSprite::update()
|
||||
}
|
||||
}
|
||||
|
||||
// Añade un path vertical
|
||||
// Añade un recorrido vertical
|
||||
void PathSprite::addVerticalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter)
|
||||
{
|
||||
paths_.emplace_back(createVerticalPath(start, end, steps), waiting_counter);
|
||||
}
|
||||
|
||||
// Añade un path horizontal
|
||||
// Añade un recorrido horizontal
|
||||
void PathSprite::addHorizontalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter)
|
||||
{
|
||||
paths_.emplace_back(createHorizontalPath(start, end, steps), waiting_counter);
|
||||
}
|
||||
|
||||
// Devuelve un vector con los puntos que conforman la ruta
|
||||
std::vector<SDL_Point> PathSprite::createVerticalPath(SDL_Point start, SDL_Point end, int steps)
|
||||
// Añade un recorrido desde un vector
|
||||
void PathSprite::addPath(std::vector<SDL_Point> spots, int waiting_counter)
|
||||
{
|
||||
std::vector<SDL_Point> v;
|
||||
v.reserve(steps);
|
||||
|
||||
for (int i = 0; i < steps; ++i)
|
||||
{
|
||||
double t = static_cast<double>(i) / steps;
|
||||
double value = static_cast<double>(start.y) + (end.y - start.y) * easeOutQuint(t);
|
||||
v.emplace_back(SDL_Point{start.x, static_cast<int>(value)});
|
||||
}
|
||||
|
||||
return v;
|
||||
paths_.emplace_back(spots, waiting_counter);
|
||||
}
|
||||
|
||||
std::vector<SDL_Point> PathSprite::createVerticalPath(const SDL_Point& start, const SDL_Point& end, int steps) {
|
||||
std::vector<SDL_Point> v;
|
||||
v.reserve(steps);
|
||||
|
||||
for (int i = 0; i < steps; ++i) {
|
||||
double t = static_cast<double>(i) / steps;
|
||||
double value = start.y + (end.y - start.y) * easeOutQuint(t);
|
||||
|
||||
// Ajusta el valor si los puntos tienen signos diferentes
|
||||
if (start.y > 0 && end.y < 0) {
|
||||
value = start.y - std::abs(end.y - start.y) * easeOutQuint(t);
|
||||
} else if (start.y < 0 && end.y > 0) {
|
||||
value = start.y + std::abs(end.y - start.y) * easeOutQuint(t);
|
||||
}
|
||||
|
||||
v.emplace_back(SDL_Point{start.x, static_cast<int>(value)});
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
// Devuelve un vector con los puntos que conforman la ruta
|
||||
std::vector<SDL_Point> PathSprite::createHorizontalPath(SDL_Point start, SDL_Point end, int steps)
|
||||
{
|
||||
@@ -66,6 +78,7 @@ void PathSprite::enable()
|
||||
enabled_ = true;
|
||||
}
|
||||
|
||||
// Coloca el sprite en los diferentes puntos del recorrido
|
||||
void PathSprite::moveThroughCurrentPath()
|
||||
{
|
||||
auto &path = paths_.at(current_path_);
|
||||
@@ -92,6 +105,7 @@ void PathSprite::moveThroughCurrentPath()
|
||||
--path.waiting_counter;
|
||||
}
|
||||
|
||||
// Cambia de recorrido o finaliza
|
||||
void PathSprite::goToNextPathOrDie()
|
||||
{
|
||||
// Comprueba si ha terminado el recorrdo actual
|
||||
|
||||
Reference in New Issue
Block a user