Retocados nombres de variables antiguos
This commit is contained in:
@@ -22,12 +22,12 @@ Actor::Actor(actor_t actor)
|
|||||||
// Obten el resto de valores
|
// Obten el resto de valores
|
||||||
sprite->setPosX(actor.x);
|
sprite->setPosX(actor.x);
|
||||||
sprite->setPosY(actor.y);
|
sprite->setPosY(actor.y);
|
||||||
|
sprite->setWidth(actor.w);
|
||||||
|
sprite->setHeight(actor.h);
|
||||||
|
|
||||||
sprite->setVelX(actor.vx);
|
sprite->setVelX(actor.vx);
|
||||||
sprite->setVelY(actor.vy);
|
sprite->setVelY(actor.vy);
|
||||||
|
|
||||||
// Inicializa el sprite con el resto de parametros comunes
|
|
||||||
sprite->setWidth(actor.w);
|
|
||||||
sprite->setHeight(actor.h);
|
|
||||||
sprite->setFlip(actor.vx>0?SDL_FLIP_NONE:SDL_FLIP_HORIZONTAL);
|
sprite->setFlip(actor.vx>0?SDL_FLIP_NONE:SDL_FLIP_HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,16 @@
|
|||||||
#ifndef ACTOR_H
|
#ifndef ACTOR_H
|
||||||
#define ACTOR_H
|
#define ACTOR_H
|
||||||
|
|
||||||
|
// Tipos de actores
|
||||||
|
enum actor_name_e
|
||||||
|
{
|
||||||
|
a_moving_platform,
|
||||||
|
a_key,
|
||||||
|
a_heart,
|
||||||
|
a_diamond,
|
||||||
|
a_door
|
||||||
|
};
|
||||||
|
|
||||||
// Estructura para pasar los datos de un enemigo
|
// Estructura para pasar los datos de un enemigo
|
||||||
struct actor_t
|
struct actor_t
|
||||||
{
|
{
|
||||||
@@ -22,6 +32,7 @@ struct actor_t
|
|||||||
float y; // Posición inicial en el eje Y
|
float y; // Posición inicial en el eje Y
|
||||||
float vx; // Velocidad en el eje X
|
float vx; // Velocidad en el eje X
|
||||||
float vy; // Velocidad en el eje Y
|
float vy; // Velocidad en el eje Y
|
||||||
|
actor_name_e name; // Tipo de actor
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clase Actor
|
// Clase Actor
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ int AnimatedSprite::getIndex(std::string name)
|
|||||||
// Calcula el frame correspondiente a la animación
|
// Calcula el frame correspondiente a la animación
|
||||||
void AnimatedSprite::animate()
|
void AnimatedSprite::animate()
|
||||||
{
|
{
|
||||||
if (mEnabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
// Calcula el frame actual a partir del contador
|
// Calcula el frame actual a partir del contador
|
||||||
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
|||||||
section.name = SECTION_PROG_GAME;
|
section.name = SECTION_PROG_GAME;
|
||||||
section.subsection = SUBSECTION_GAME_PLAY;
|
section.subsection = SUBSECTION_GAME_PLAY;
|
||||||
|
|
||||||
debug = false;
|
debug = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -145,7 +145,7 @@ void Game::renderDebugInfo()
|
|||||||
text = "D - Toggle debug mode";
|
text = "D - Toggle debug mode";
|
||||||
debugText->write(1, 216, text, -1);
|
debugText->write(1, 216, text, -1);
|
||||||
|
|
||||||
text = std::to_string((int)player->sprite->getPosX()) + "," + std::to_string((int)player->sprite->getPosY());
|
text = std::to_string((int)player->sprite->getPosX()) + "," + std::to_string((int)player->sprite->getPosY()) + "," + std::to_string((int)player->sprite->getWidth()) + "," + std::to_string((int)player->sprite->getHeight());
|
||||||
debugText->write(0, line, text, -1);
|
debugText->write(0, line, text, -1);
|
||||||
|
|
||||||
text = "VY " + std::to_string(player->vy) + " " + std::to_string(player->jumpStrenght);
|
text = "VY " + std::to_string(player->vy) + " " + std::to_string(player->jumpStrenght);
|
||||||
@@ -171,6 +171,14 @@ void Game::renderDebugInfo()
|
|||||||
|
|
||||||
text = map->getRoomFileName(b_top) + " " + map->getRoomFileName(b_right) + " " + map->getRoomFileName(b_bottom) + " " + map->getRoomFileName(b_left);
|
text = map->getRoomFileName(b_top) + " " + map->getRoomFileName(b_right) + " " + map->getRoomFileName(b_bottom) + " " + map->getRoomFileName(b_left);
|
||||||
debugText->write(0, line += 6, text, -1);
|
debugText->write(0, line += 6, text, -1);
|
||||||
|
|
||||||
|
text = "ACTOR = " + std::to_string(player->checkActors());
|
||||||
|
debugText->write(0, line += 6, text, -1);
|
||||||
|
|
||||||
|
// Pinta mascaras
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 128);
|
||||||
|
SDL_Rect rect = player->sprite->getRect();
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el mapa
|
// Cambia el mapa
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ bool Map::load(std::string file_path)
|
|||||||
actor_t actor;
|
actor_t actor;
|
||||||
actor.asset = asset;
|
actor.asset = asset;
|
||||||
actor.renderer = renderer;
|
actor.renderer = renderer;
|
||||||
|
actor.name = a_moving_platform;
|
||||||
SDL_Point p1, p2;
|
SDL_Point p1, p2;
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -266,11 +267,11 @@ bool Map::setActor(actor_t *actor, SDL_Point *p1, SDL_Point *p2, std::string var
|
|||||||
}
|
}
|
||||||
else if (var == "width")
|
else if (var == "width")
|
||||||
{
|
{
|
||||||
actor->w = std::stof(value);
|
actor->w = std::stoi(value);
|
||||||
}
|
}
|
||||||
else if (var == "height")
|
else if (var == "height")
|
||||||
{
|
{
|
||||||
actor->h = std::stof(value);
|
actor->h = std::stoi(value);
|
||||||
}
|
}
|
||||||
else if (var == "x")
|
else if (var == "x")
|
||||||
{
|
{
|
||||||
@@ -487,3 +488,19 @@ std::string Map::getRoomFileName(e_border border)
|
|||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Indica si hay colision con un actor a partir de un rectangulo
|
||||||
|
int Map::actorCollision(SDL_Rect &rect)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
for (auto actor : actors)
|
||||||
|
{
|
||||||
|
if (checkCollision(rect, actor->getCollider()))
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
@@ -91,6 +91,9 @@ public:
|
|||||||
|
|
||||||
// Devuelve el nombre del fichero de la habitación en funcion del borde
|
// Devuelve el nombre del fichero de la habitación en funcion del borde
|
||||||
std::string getRoomFileName(e_border border);
|
std::string getRoomFileName(e_border border);
|
||||||
|
|
||||||
|
// Indica si hay colision con un actor a partir de un rectangulo
|
||||||
|
int actorCollision(SDL_Rect &rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,50 +5,50 @@
|
|||||||
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, LTexture *texture, SDL_Renderer *renderer)
|
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, LTexture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
setTexture(texture);
|
this->texture = texture;
|
||||||
setRenderer(renderer);
|
this->renderer = renderer;
|
||||||
|
|
||||||
// Establece el alto y el ancho del sprite
|
// Establece el alto y el ancho del sprite
|
||||||
setWidth(w);
|
this->w = w;
|
||||||
setHeight(h);
|
this->h = h;
|
||||||
|
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
setPosX(x);
|
this->x = x;
|
||||||
setPosY(y);
|
this->y = y;
|
||||||
mPosXPrev = x;
|
xPrev = x;
|
||||||
mPosYPrev = y;
|
yPrev = y;
|
||||||
|
|
||||||
// Establece la velocidad X,Y del sprite
|
// Establece la velocidad X,Y del sprite
|
||||||
setVelX(velx);
|
vx = velx;
|
||||||
setVelY(vely);
|
vy = vely;
|
||||||
|
|
||||||
// Establece la aceleración X,Y del sprite
|
// Establece la aceleración X,Y del sprite
|
||||||
setAccelX(accelx);
|
ax = accelx;
|
||||||
setAccelY(accely);
|
ay = accely;
|
||||||
|
|
||||||
// Establece el zoom W,H del sprite
|
// Establece el zoom W,H del sprite
|
||||||
setZoomW(1);
|
zoomW = 1;
|
||||||
setZoomH(1);
|
zoomH = 1;
|
||||||
|
|
||||||
// Establece el angulo con el que se dibujará
|
// Establece el angulo con el que se dibujará
|
||||||
setAngle(0.0);
|
angle = (double)0;
|
||||||
|
|
||||||
// Establece los valores de rotacion
|
// Establece los valores de rotacion
|
||||||
setRotate(false);
|
rotateEnabled = false;
|
||||||
setRotateSpeed(0);
|
rotateSpeed = 0;
|
||||||
setRotateAmount(0.0);
|
rotateAmount = (double)0;
|
||||||
|
|
||||||
// Contador interno
|
// Contador interno
|
||||||
mCounter = 0;
|
counter = 0;
|
||||||
|
|
||||||
// Establece el rectangulo de donde coger la imagen
|
// Establece el rectangulo de donde coger la imagen
|
||||||
setSpriteClip(0, 0, w, h);
|
spriteClip = {0, 0, w, h};
|
||||||
|
|
||||||
// Establece el centro de rotación
|
// Establece el centro de rotación
|
||||||
mCenter = {0, 0};
|
center = {0, 0};
|
||||||
|
|
||||||
// Establece el tipo de volteado
|
// Establece el tipo de volteado
|
||||||
mFlip = SDL_FLIP_NONE;
|
currentFlip = SDL_FLIP_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -59,199 +59,199 @@ MovingSprite::~MovingSprite()
|
|||||||
// Reinicia todas las variables
|
// Reinicia todas las variables
|
||||||
void MovingSprite::clear()
|
void MovingSprite::clear()
|
||||||
{
|
{
|
||||||
mPosX = 0.0f; // Posición en el eje X
|
x = 0.0f; // Posición en el eje X
|
||||||
mPosY = 0.0f; // Posición en el eje Y
|
y = 0.0f; // Posición en el eje Y
|
||||||
|
|
||||||
mVelX = 0.0f; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
vx = 0.0f; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||||
mVelY = 0.0f; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
vy = 0.0f; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||||
|
|
||||||
mAccelX = 0.0f; // Aceleración en el eje X. Variación de la velocidad
|
ax = 0.0f; // Aceleración en el eje X. Variación de la velocidad
|
||||||
mAccelY = 0.0f; // Aceleración en el eje Y. Variación de la velocidad
|
ay = 0.0f; // Aceleración en el eje Y. Variación de la velocidad
|
||||||
|
|
||||||
mZoomW = 1.0f; // Zoom aplicado a la anchura
|
zoomW = 1.0f; // Zoom aplicado a la anchura
|
||||||
mZoomH = 1.0f; // Zoom aplicado a la altura
|
zoomH = 1.0f; // Zoom aplicado a la altura
|
||||||
|
|
||||||
mAngle = 0.0; // Angulo para dibujarlo
|
angle = 0.0; // Angulo para dibujarlo
|
||||||
mRotate = false; // Indica si ha de rotar
|
rotateEnabled = false; // Indica si ha de rotar
|
||||||
mCenter = {0, 0}; // Centro de rotación
|
center = {0, 0}; // Centro de rotación
|
||||||
mRotateSpeed = 0; // Velocidad de giro
|
rotateSpeed = 0; // Velocidad de giro
|
||||||
mRotateAmount = 0.0; // Cantidad de grados a girar en cada iteración
|
rotateAmount = 0.0; // Cantidad de grados a girar en cada iteración
|
||||||
mCounter = 0; // Contador interno
|
counter = 0; // Contador interno
|
||||||
|
|
||||||
mFlip = SDL_FLIP_NONE; // Establece como se ha de voltear el sprite
|
currentFlip = SDL_FLIP_NONE; // Establece como se ha de voltear el sprite
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mueve el sprite
|
// Mueve el sprite
|
||||||
void MovingSprite::move()
|
void MovingSprite::move()
|
||||||
{
|
{
|
||||||
if (mEnabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
mPosXPrev = mPosX;
|
xPrev = x;
|
||||||
mPosYPrev = mPosY;
|
yPrev = y;
|
||||||
|
|
||||||
mPosX += mVelX;
|
x += vx;
|
||||||
mPosY += mVelY;
|
y += vy;
|
||||||
|
|
||||||
mVelX += mAccelX;
|
vx += ax;
|
||||||
mVelY += mAccelY;
|
vy += ay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra el sprite por pantalla
|
// Muestra el sprite por pantalla
|
||||||
void MovingSprite::render()
|
void MovingSprite::render()
|
||||||
{
|
{
|
||||||
if (mEnabled)
|
if (enabled)
|
||||||
mTexture->render(mRenderer, (int)mPosX, (int)mPosY, &mSpriteClip, mZoomW, mZoomH, mAngle, &mCenter, mFlip);
|
texture->render(renderer, (int)x, (int)y, &spriteClip, zoomW, zoomH, angle, ¢er, currentFlip);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getPosX()
|
float MovingSprite::getPosX()
|
||||||
{
|
{
|
||||||
return mPosX;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getPosY()
|
float MovingSprite::getPosY()
|
||||||
{
|
{
|
||||||
return mPosY;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getVelX()
|
float MovingSprite::getVelX()
|
||||||
{
|
{
|
||||||
return mVelX;
|
return vx;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getVelY()
|
float MovingSprite::getVelY()
|
||||||
{
|
{
|
||||||
return mVelY;
|
return vy;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getAccelX()
|
float MovingSprite::getAccelX()
|
||||||
{
|
{
|
||||||
return mAccelX;
|
return ax;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getAccelY()
|
float MovingSprite::getAccelY()
|
||||||
{
|
{
|
||||||
return mAccelY;
|
return ay;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getZoomW()
|
float MovingSprite::getZoomW()
|
||||||
{
|
{
|
||||||
return mZoomW;
|
return zoomW;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float MovingSprite::getZoomH()
|
float MovingSprite::getZoomH()
|
||||||
{
|
{
|
||||||
return mZoomH;
|
return zoomH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
double MovingSprite::getAngle()
|
double MovingSprite::getAngle()
|
||||||
{
|
{
|
||||||
return mAngle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición del objeto
|
||||||
void MovingSprite::setPos(SDL_Rect rect)
|
void MovingSprite::setPos(SDL_Rect rect)
|
||||||
{
|
{
|
||||||
mPosX = (float)rect.x;
|
x = (float)rect.x;
|
||||||
mPosY = (float)rect.y;
|
y = (float)rect.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setPosX(float x)
|
void MovingSprite::setPosX(float value)
|
||||||
{
|
{
|
||||||
mPosX = x;
|
x = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setPosY(float y)
|
void MovingSprite::setPosY(float value)
|
||||||
{
|
{
|
||||||
mPosY = y;
|
y = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setVelX(float x)
|
void MovingSprite::setVelX(float value)
|
||||||
{
|
{
|
||||||
mVelX = x;
|
vx = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setVelY(float y)
|
void MovingSprite::setVelY(float value)
|
||||||
{
|
{
|
||||||
mVelY = y;
|
vy = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setAccelX(float x)
|
void MovingSprite::setAccelX(float value)
|
||||||
{
|
{
|
||||||
mAccelX = x;
|
ax = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setAccelY(float y)
|
void MovingSprite::setAccelY(float value)
|
||||||
{
|
{
|
||||||
mAccelY = y;
|
ay = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setZoomW(float w)
|
void MovingSprite::setZoomW(float value)
|
||||||
{
|
{
|
||||||
mZoomW = w;
|
zoomW = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setZoomH(float h)
|
void MovingSprite::setZoomH(float value)
|
||||||
{
|
{
|
||||||
mZoomH = h;
|
zoomH = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setAngle(double a)
|
void MovingSprite::setAngle(double value)
|
||||||
{
|
{
|
||||||
mAngle = a;
|
angle = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incrementa el valor de la variable
|
// Incrementa el valor de la variable
|
||||||
void MovingSprite::incAngle(double inc)
|
void MovingSprite::incAngle(double value)
|
||||||
{
|
{
|
||||||
mAngle += inc;
|
angle += value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrementa el valor de la variable
|
// Decrementa el valor de la variable
|
||||||
void MovingSprite::decAngle(double dec)
|
void MovingSprite::decAngle(double value)
|
||||||
{
|
{
|
||||||
mAngle -= dec;
|
angle -= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
bool MovingSprite::getRotate()
|
bool MovingSprite::getRotate()
|
||||||
{
|
{
|
||||||
return mRotate;
|
return rotateEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
Uint16 MovingSprite::getRotateSpeed()
|
Uint16 MovingSprite::getRotateSpeed()
|
||||||
{
|
{
|
||||||
return mRotateSpeed;
|
return rotateSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la rotacion
|
// Establece la rotacion
|
||||||
void MovingSprite::rotate()
|
void MovingSprite::rotate()
|
||||||
{
|
{
|
||||||
if (mEnabled)
|
if (enabled)
|
||||||
if (mRotate)
|
if (rotateEnabled)
|
||||||
{
|
{
|
||||||
if (mCounter % mRotateSpeed == 0)
|
if (counter % rotateSpeed == 0)
|
||||||
{
|
{
|
||||||
incAngle(mRotateAmount);
|
incAngle(rotateAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,26 +259,26 @@ void MovingSprite::rotate()
|
|||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setRotate(bool value)
|
void MovingSprite::setRotate(bool value)
|
||||||
{
|
{
|
||||||
mRotate = value;
|
rotateEnabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setRotateSpeed(Uint16 value)
|
void MovingSprite::setRotateSpeed(int value)
|
||||||
{
|
{
|
||||||
mRotateSpeed = value;
|
rotateSpeed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setRotateAmount(double value)
|
void MovingSprite::setRotateAmount(double value)
|
||||||
{
|
{
|
||||||
mRotateAmount = value;
|
rotateAmount = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::disableRotate()
|
void MovingSprite::disableRotate()
|
||||||
{
|
{
|
||||||
mRotate = false;
|
rotateEnabled = false;
|
||||||
mAngle = 0;
|
angle = (double)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables internas del objeto
|
// Actualiza las variables internas del objeto
|
||||||
@@ -287,62 +287,73 @@ void MovingSprite::update()
|
|||||||
move();
|
move();
|
||||||
rotate();
|
rotate();
|
||||||
|
|
||||||
if (mEnabled)
|
if (enabled)
|
||||||
++mCounter %= 60000;
|
{
|
||||||
|
++counter %= 60000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el sentido de la rotación
|
// Cambia el sentido de la rotación
|
||||||
void MovingSprite::switchRotate()
|
void MovingSprite::switchRotate()
|
||||||
{
|
{
|
||||||
mRotateAmount *= -1;
|
rotateAmount *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setFlip(SDL_RendererFlip flip)
|
void MovingSprite::setFlip(SDL_RendererFlip flip)
|
||||||
{
|
{
|
||||||
mFlip = flip;
|
currentFlip = flip;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gira el sprite horizontalmente
|
// Gira el sprite horizontalmente
|
||||||
void MovingSprite::flip()
|
void MovingSprite::flip()
|
||||||
{
|
{
|
||||||
mFlip = (mFlip==SDL_FLIP_HORIZONTAL)?SDL_FLIP_NONE:SDL_FLIP_HORIZONTAL;
|
currentFlip = (currentFlip == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
SDL_RendererFlip MovingSprite::getFlip()
|
SDL_RendererFlip MovingSprite::getFlip()
|
||||||
{
|
{
|
||||||
return mFlip;
|
return currentFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect MovingSprite::getRect()
|
SDL_Rect MovingSprite::getRect()
|
||||||
{
|
{
|
||||||
SDL_Rect rect = {(int)getPosX(), (int)getPosY(), getWidth(), getHeight()};
|
const SDL_Rect rect = {(int)x, (int)y, w, h};
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Establece los valores de posición y tamaño del sprite
|
||||||
|
void MovingSprite::setRect(SDL_Rect rect)
|
||||||
|
{
|
||||||
|
x = (float)rect.x;
|
||||||
|
y = (float)rect.y;
|
||||||
|
w = rect.w;
|
||||||
|
h = rect.h;
|
||||||
|
}
|
||||||
|
|
||||||
// Deshace el último movimiento
|
// Deshace el último movimiento
|
||||||
void MovingSprite::undoMove()
|
void MovingSprite::undoMove()
|
||||||
{
|
{
|
||||||
mPosX = mPosXPrev;
|
x = xPrev;
|
||||||
mPosY = mPosYPrev;
|
y = yPrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deshace el último movimiento en el eje X
|
// Deshace el último movimiento en el eje X
|
||||||
void MovingSprite::undoMoveX()
|
void MovingSprite::undoMoveX()
|
||||||
{
|
{
|
||||||
mPosX = mPosXPrev;
|
x = xPrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deshace el último movimiento en el eje Y
|
// Deshace el último movimiento en el eje Y
|
||||||
void MovingSprite::undoMoveY()
|
void MovingSprite::undoMoveY()
|
||||||
{
|
{
|
||||||
mPosY = mPosYPrev;
|
y = yPrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone a cero las velocidades de desplacamiento
|
// Pone a cero las velocidades de desplacamiento
|
||||||
void MovingSprite::clearVel()
|
void MovingSprite::clearVel()
|
||||||
{
|
{
|
||||||
mVelX = mVelY = 0;
|
vx = vy = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -10,28 +10,28 @@
|
|||||||
class MovingSprite : public Sprite
|
class MovingSprite : public Sprite
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float mPosX; // Posición en el eje X
|
float x; // Posición en el eje X
|
||||||
float mPosY; // Posición en el eje Y
|
float y; // Posición en el eje Y
|
||||||
|
|
||||||
float mPosXPrev; // Posición anterior en el eje X
|
float xPrev; // Posición anterior en el eje X
|
||||||
float mPosYPrev; // Posición anterior en el eje Y
|
float yPrev; // Posición anterior en el eje Y
|
||||||
|
|
||||||
float mVelX; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
float vx; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||||
float mVelY; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
float vy; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||||
|
|
||||||
float mAccelX; // Aceleración en el eje X. Variación de la velocidad
|
float ax; // Aceleración en el eje X. Variación de la velocidad
|
||||||
float mAccelY; // Aceleración en el eje Y. Variación de la velocidad
|
float ay; // Aceleración en el eje Y. Variación de la velocidad
|
||||||
|
|
||||||
float mZoomW; // Zoom aplicado a la anchura
|
float zoomW; // Zoom aplicado a la anchura
|
||||||
float mZoomH; // Zoom aplicado a la altura
|
float zoomH; // Zoom aplicado a la altura
|
||||||
|
|
||||||
double mAngle; // Angulo para dibujarlo
|
double angle; // Angulo para dibujarlo
|
||||||
bool mRotate; // Indica si ha de rotar
|
bool rotateEnabled; // Indica si ha de rotar
|
||||||
Uint16 mRotateSpeed; // Velocidad de giro
|
int rotateSpeed; // Velocidad de giro
|
||||||
double mRotateAmount; // Cantidad de grados a girar en cada iteración
|
double rotateAmount; // Cantidad de grados a girar en cada iteración
|
||||||
Uint16 mCounter; // Contador interno
|
int counter; // Contador interno
|
||||||
SDL_Point mCenter; // Centro de rotación
|
SDL_Point center; // Centro de rotación
|
||||||
SDL_RendererFlip mFlip; // Indica como se voltea el sprite
|
SDL_RendererFlip currentFlip; // Indica como se voltea el sprite
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -92,43 +92,43 @@ public:
|
|||||||
void setPos(SDL_Rect rect);
|
void setPos(SDL_Rect rect);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setPosX(float x);
|
void setPosX(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setPosY(float y);
|
void setPosY(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setVelX(float x);
|
void setVelX(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setVelY(float y);
|
void setVelY(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setAccelX(float x);
|
void setAccelX(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setAccelY(float y);
|
void setAccelY(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setZoomW(float w);
|
void setZoomW(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setZoomH(float h);
|
void setZoomH(float value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setAngle(double a);
|
void setAngle(double vaue);
|
||||||
|
|
||||||
// Incrementa el valor de la variable
|
// Incrementa el valor de la variable
|
||||||
void incAngle(double inc);
|
void incAngle(double value);
|
||||||
|
|
||||||
// Decrementa el valor de la variable
|
// Decrementa el valor de la variable
|
||||||
void decAngle(double dec);
|
void decAngle(double value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setRotate(bool value);
|
void setRotate(bool value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setRotateSpeed(Uint16 value);
|
void setRotateSpeed(int value);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setRotateAmount(double value);
|
void setRotateAmount(double value);
|
||||||
@@ -151,6 +151,9 @@ public:
|
|||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect getRect();
|
SDL_Rect getRect();
|
||||||
|
|
||||||
|
// Establece los valores de posición y tamaño del sprite
|
||||||
|
void setRect(SDL_Rect rect);
|
||||||
|
|
||||||
// Deshace el último movimiento
|
// Deshace el último movimiento
|
||||||
void undoMove();
|
void undoMove();
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map)
|
|||||||
vx = 0;
|
vx = 0;
|
||||||
vy = 0;
|
vy = 0;
|
||||||
lastPosition = {(int)x, (int)y};
|
lastPosition = {(int)x, (int)y};
|
||||||
const SDL_Rect rect = {(int)x, (int)y, 16, 24};
|
const SDL_Rect rect = {(int)x, (int)y, w, h};
|
||||||
sprite->setPos(rect);
|
sprite->setRect(rect);
|
||||||
sprite->setCurrentAnimation("stand");
|
sprite->setCurrentAnimation("stand");
|
||||||
sprite->setFlip(SDL_FLIP_NONE);
|
sprite->setFlip(SDL_FLIP_NONE);
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ Player::~Player()
|
|||||||
void Player::update()
|
void Player::update()
|
||||||
{
|
{
|
||||||
checkInput();
|
checkInput();
|
||||||
// addGravity();
|
|
||||||
move();
|
move();
|
||||||
animate();
|
animate();
|
||||||
|
checkActors();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el objeto
|
// Dibuja el objeto
|
||||||
@@ -373,3 +373,10 @@ void Player::setMap(Map *map)
|
|||||||
{
|
{
|
||||||
this->map = map;
|
this->map = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba las interacciones con los actores
|
||||||
|
int Player::checkActors()
|
||||||
|
{
|
||||||
|
SDL_Rect rect = sprite->getRect();
|
||||||
|
return map->actorCollision(rect);
|
||||||
|
}
|
||||||
@@ -83,6 +83,9 @@ public:
|
|||||||
// Comprueba si el jugador tiene suelo debajo de los pies
|
// Comprueba si el jugador tiene suelo debajo de los pies
|
||||||
bool isOnFloor();
|
bool isOnFloor();
|
||||||
|
|
||||||
|
// Comprueba las interacciones con los actores
|
||||||
|
int checkActors();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map);
|
Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map);
|
||||||
|
|||||||
@@ -3,175 +3,181 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
Sprite::Sprite(int x, int y, int w, int h, LTexture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(int x, int y, int w, int h, LTexture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece el alto y el ancho del sprite
|
|
||||||
setWidth(w);
|
|
||||||
setHeight(h);
|
|
||||||
|
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
setPosX(x);
|
this->x = x;
|
||||||
setPosY(y);
|
this->y = y;
|
||||||
|
|
||||||
|
// Establece el alto y el ancho del sprite
|
||||||
|
this->w = w;
|
||||||
|
this->h = h;
|
||||||
|
|
||||||
// Establece el puntero al renderizador de la ventana
|
// Establece el puntero al renderizador de la ventana
|
||||||
setRenderer(renderer);
|
this->renderer = renderer;
|
||||||
|
|
||||||
// Establece la textura donde están los gráficos para el sprite
|
// Establece la textura donde están los gráficos para el sprite
|
||||||
setTexture(texture);
|
this->texture = texture;
|
||||||
|
|
||||||
// Establece el rectangulo de donde coger la imagen
|
// Establece el rectangulo de donde coger la imagen
|
||||||
setSpriteClip(x, y, w, h);
|
spriteClip = {x, y, w, h};
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
setEnabled(true);
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite::Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece el alto y el ancho del sprite
|
|
||||||
setWidth(rect.w);
|
|
||||||
setHeight(rect.h);
|
|
||||||
|
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
setPosX(rect.x);
|
x = rect.x;
|
||||||
setPosY(rect.y);
|
y = rect.y;
|
||||||
|
|
||||||
|
// Establece el alto y el ancho del sprite
|
||||||
|
w = rect.w;
|
||||||
|
h = rect.h;
|
||||||
|
|
||||||
// Establece el puntero al renderizador de la ventana
|
// Establece el puntero al renderizador de la ventana
|
||||||
setRenderer(renderer);
|
this->renderer = renderer;
|
||||||
|
|
||||||
// Establece la textura donde están los gráficos para el sprite
|
// Establece la textura donde están los gráficos para el sprite
|
||||||
setTexture(texture);
|
this->texture = texture;
|
||||||
|
|
||||||
// Establece el rectangulo de donde coger la imagen
|
// Establece el rectangulo de donde coger la imagen
|
||||||
setSpriteClip(rect);
|
spriteClip = {x, y, w, h};
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
setEnabled(true);
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Sprite::~Sprite()
|
Sprite::~Sprite()
|
||||||
{
|
{
|
||||||
mTexture = nullptr;
|
texture = nullptr;
|
||||||
mRenderer = nullptr;
|
renderer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra el sprite por pantalla
|
// Muestra el sprite por pantalla
|
||||||
void Sprite::render()
|
void Sprite::render()
|
||||||
{
|
{
|
||||||
if (mEnabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
mTexture->render(mRenderer, mPosX, mPosY, &mSpriteClip);
|
texture->render(renderer, x, y, &spriteClip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
int Sprite::getPosX()
|
int Sprite::getPosX()
|
||||||
{
|
{
|
||||||
return mPosX;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
int Sprite::getPosY()
|
int Sprite::getPosY()
|
||||||
{
|
{
|
||||||
return mPosY;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
int Sprite::getWidth()
|
int Sprite::getWidth()
|
||||||
{
|
{
|
||||||
return mWidth;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
int Sprite::getHeight()
|
int Sprite::getHeight()
|
||||||
{
|
{
|
||||||
return mHeight;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición del objeto
|
||||||
void Sprite::setPos(SDL_Rect rect)
|
void Sprite::setPos(SDL_Rect rect)
|
||||||
{
|
{
|
||||||
mPosX = rect.x;
|
x = rect.x;
|
||||||
mPosY = rect.y;
|
y = rect.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setPosX(int x)
|
void Sprite::setPosX(int x)
|
||||||
{
|
{
|
||||||
mPosX = x;
|
this->x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setPosY(int y)
|
void Sprite::setPosY(int y)
|
||||||
{
|
{
|
||||||
mPosY = y;
|
this->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setWidth(int w)
|
void Sprite::setWidth(int w)
|
||||||
{
|
{
|
||||||
mWidth = w;
|
this->w = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setHeight(int h)
|
void Sprite::setHeight(int h)
|
||||||
{
|
{
|
||||||
mHeight = h;
|
this->h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
SDL_Rect Sprite::getSpriteClip()
|
SDL_Rect Sprite::getSpriteClip()
|
||||||
{
|
{
|
||||||
return mSpriteClip;
|
return spriteClip;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setSpriteClip(SDL_Rect rect)
|
void Sprite::setSpriteClip(SDL_Rect rect)
|
||||||
{
|
{
|
||||||
mSpriteClip = rect;
|
spriteClip = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setSpriteClip(int x, int y, int w, int h)
|
void Sprite::setSpriteClip(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
mSpriteClip.x = x;
|
spriteClip = {x, y, w, h};
|
||||||
mSpriteClip.y = y;
|
|
||||||
mSpriteClip.w = w;
|
|
||||||
mSpriteClip.h = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
LTexture *Sprite::getTexture()
|
LTexture *Sprite::getTexture()
|
||||||
{
|
{
|
||||||
return mTexture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setTexture(LTexture *texture)
|
void Sprite::setTexture(LTexture *texture)
|
||||||
{
|
{
|
||||||
mTexture = texture;
|
this->texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setRenderer(SDL_Renderer *renderer)
|
void Sprite::setRenderer(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
mRenderer = renderer;
|
this->renderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setEnabled(bool value)
|
void Sprite::setEnabled(bool value)
|
||||||
{
|
{
|
||||||
mEnabled = value;
|
enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si el objeto está habilitado
|
// Comprueba si el objeto está habilitado
|
||||||
bool Sprite::isEnabled()
|
bool Sprite::isEnabled()
|
||||||
{
|
{
|
||||||
return mEnabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect Sprite::getRect()
|
SDL_Rect Sprite::getRect()
|
||||||
{
|
{
|
||||||
SDL_Rect rect = {getPosX(), getPosY(), getWidth(), getHeight()};
|
SDL_Rect rect = {x, y, w, h};
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Establece los valores de posición y tamaño del sprite
|
||||||
|
void Sprite::setRect(SDL_Rect rect)
|
||||||
|
{
|
||||||
|
x = rect.x;
|
||||||
|
y = rect.y;
|
||||||
|
w = rect.w;
|
||||||
|
h = rect.h;
|
||||||
|
}
|
||||||
@@ -10,16 +10,16 @@
|
|||||||
class Sprite
|
class Sprite
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int mPosX; // Posición en el eje X donde dibujar el sprite
|
int x; // Posición en el eje X donde dibujar el sprite
|
||||||
int mPosY; // Posición en el eje Y donde dibujar el sprite
|
int y; // Posición en el eje Y donde dibujar el sprite
|
||||||
Uint16 mWidth; // Ancho del sprite
|
int w; // Ancho del sprite
|
||||||
Uint16 mHeight; // Alto del sprite
|
int h; // Alto del sprite
|
||||||
|
|
||||||
SDL_Renderer *mRenderer; // Puntero al renderizador de la ventana
|
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||||
LTexture *mTexture; // Textura donde estan todos los dibujos del sprite
|
LTexture *texture; // Textura donde estan todos los dibujos del sprite
|
||||||
SDL_Rect mSpriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||||
|
|
||||||
bool mEnabled; // Indica si el sprite esta habilitado
|
bool enabled; // Indica si el sprite esta habilitado
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -85,6 +85,9 @@ public:
|
|||||||
|
|
||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect getRect();
|
SDL_Rect getRect();
|
||||||
|
|
||||||
|
// Establece los valores de posición y tamaño del sprite
|
||||||
|
void setRect(SDL_Rect rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user