79 lines
1.8 KiB
C++
79 lines
1.8 KiB
C++
#pragma once
|
|
#include "ifdefs.h"
|
|
#include "sprite.h"
|
|
|
|
#ifndef MOVINGSPRITE_H
|
|
#define MOVINGSPRITE_H
|
|
|
|
// Clase MovingSprite. Añade posicion y velocidad en punto flotante
|
|
class MovingSprite : public Sprite
|
|
{
|
|
public:
|
|
// Constructor
|
|
MovingSprite();
|
|
|
|
// Destructor
|
|
~MovingSprite();
|
|
|
|
// Iniciador
|
|
void init(float x, float y, Uint16 w, Uint16 h, float velx, float vely, float accelx, float accely,
|
|
LTexture *texture, SDL_Renderer *renderer);
|
|
|
|
// Coloca el sprite en su nueva posición en funcion de la velocidad
|
|
void move();
|
|
|
|
// Actualiza las variables internas del sprite: posición y velocidad
|
|
void update();
|
|
|
|
// Muestra el sprite por pantalla
|
|
void render();
|
|
|
|
// Obten el valor de la variable
|
|
float getPosX();
|
|
|
|
// Obten el valor de la variable
|
|
float getPosY();
|
|
|
|
// Obten el valor de la variable
|
|
float getVelX();
|
|
|
|
// Obten el valor de la variable
|
|
float getVelY();
|
|
|
|
// Obten el valor de la variable
|
|
float getAccelX();
|
|
|
|
// Obten el valor de la variable
|
|
float getAccelY();
|
|
|
|
// Establece el valor de la variable
|
|
void setPosX(float x);
|
|
|
|
// Establece el valor de la variable
|
|
void setPosY(float y);
|
|
|
|
// Establece el valor de la variable
|
|
void setVelX(float x);
|
|
|
|
// Establece el valor de la variable
|
|
void setVelY(float y);
|
|
|
|
// Establece el valor de la variable
|
|
void setAccelX(float x);
|
|
|
|
// Establece el valor de la variable
|
|
void setAccelY(float y);
|
|
|
|
private:
|
|
float mPosX; // Posición en el eje X
|
|
float mPosY; // Posición en el eje Y
|
|
|
|
float mVelX; // Velocidad en el eje X
|
|
float mVelY; // Velocidad en el eje Y
|
|
|
|
float mAccelX; // Aceleración en el eje X
|
|
float mAccelY; // Aceleración en el eje Y
|
|
};
|
|
|
|
#endif
|