Empezando con los actores y polimorfismo. Ya pinta la plataforma movil

This commit is contained in:
2022-08-26 13:36:31 +02:00
parent aea71599ff
commit a4000d25db
12 changed files with 120 additions and 108 deletions

View File

@@ -3,8 +3,10 @@
#include <sstream>
// Constructor
ActorMovingPlatform::ActorMovingPlatform()
ActorMovingPlatform::ActorMovingPlatform(actor_t actor, SDL_Point p1, SDL_Point p2) : Actor(actor)
{
this->p1 = p1;
this->p2 = p2;
}
// Destructor
@@ -19,14 +21,14 @@ void ActorMovingPlatform::checkPath()
if (sprite->getPosX() > p2.x || sprite->getPosX() < p1.x)
{
sprite->setVelX(sprite->getVelX() * (-1));
sprite->flip();
//sprite->flip();
}
// Comprueba los límites verticales
if (sprite->getPosY() > p2.y || sprite->getPosY() < p1.y)
{
sprite->setVelY(sprite->getVelY() * (-1));
sprite->flip();
//sprite->flip();
}
}