text2 class converted to writer class
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
#include "const.h"
|
||||
#include "text2.h"
|
||||
#include "writer.h"
|
||||
|
||||
// Constructor
|
||||
Text2::Text2(std::string file, LTexture *texture, SDL_Renderer *renderer) : Text(file, texture, renderer)
|
||||
Writer::Writer(std::string file, LTexture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Text2::~Text2()
|
||||
Writer::~Writer()
|
||||
{
|
||||
}
|
||||
|
||||
// Inicializador
|
||||
void Text2::init()
|
||||
void Writer::init()
|
||||
{
|
||||
Text::init();
|
||||
mPosX = 0;
|
||||
@@ -31,63 +31,63 @@ void Text2::init()
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setPosX(int value)
|
||||
void Writer::setPosX(int value)
|
||||
{
|
||||
mPosX = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setPosY(int value)
|
||||
void Writer::setPosY(int value)
|
||||
{
|
||||
mPosY = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setKerning(int value)
|
||||
void Writer::setKerning(int value)
|
||||
{
|
||||
mKerning = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setCaption(std::string text)
|
||||
void Writer::setCaption(std::string text)
|
||||
{
|
||||
mCaption = text;
|
||||
mLenght = text.length();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setWrittingSpeed(Uint16 value)
|
||||
void Writer::setWrittingSpeed(Uint16 value)
|
||||
{
|
||||
mWrittingSpeed = value;
|
||||
mWrittingTimer = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setEnabled(bool value)
|
||||
void Writer::setEnabled(bool value)
|
||||
{
|
||||
mEnabled = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Text2::IsEnabled()
|
||||
bool Writer::IsEnabled()
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setEnabledTimer(Uint16 value)
|
||||
void Writer::setEnabledTimer(Uint16 value)
|
||||
{
|
||||
mEnabledTimer = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 Text2::getEnabledTimer()
|
||||
Uint16 Writer::getEnabledTimer()
|
||||
{
|
||||
return mEnabledTimer;
|
||||
}
|
||||
|
||||
// Actualiza el objeto
|
||||
void Text2::update()
|
||||
void Writer::update()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
@@ -95,11 +95,11 @@ void Text2::update()
|
||||
{
|
||||
if (mWrittingTimer > 0)
|
||||
{
|
||||
--mWrittingTimer;
|
||||
mWrittingTimer--;
|
||||
}
|
||||
if (mWrittingTimer == 0)
|
||||
{
|
||||
++mIndex;
|
||||
mIndex++;
|
||||
mWrittingTimer = mWrittingSpeed;
|
||||
}
|
||||
if (mIndex == mLenght)
|
||||
@@ -111,7 +111,7 @@ void Text2::update()
|
||||
{
|
||||
if (mEnabledTimer > 0)
|
||||
{
|
||||
--mEnabledTimer;
|
||||
mEnabledTimer--;
|
||||
}
|
||||
else if (mEnabledTimer == 0)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ void Text2::update()
|
||||
}
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void Text2::render()
|
||||
void Writer::render()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
@@ -138,19 +138,19 @@ void Text2::render()
|
||||
}
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void Text2::center(int x)
|
||||
void Writer::center(int x)
|
||||
{
|
||||
setPosX(x - (lenght(mCaption, mKerning) / 2));
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setId(int id)
|
||||
void Writer::setId(int id)
|
||||
{
|
||||
mId = id;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setIntroEvents(Uint8 *value)
|
||||
void Writer::setIntroEvents(Uint8 *value)
|
||||
{
|
||||
mIntroEvents = value;
|
||||
}
|
||||
@@ -1,102 +1,80 @@
|
||||
#pragma once
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
|
||||
#ifndef TEXT2_H
|
||||
#define TEXT2_H
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Text2 : public Text
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
Text2(std::string file, LTexture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Text2();
|
||||
|
||||
// Inicializador
|
||||
void init();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setKerning(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setCaption(std::string text);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setWrittingSpeed(Uint16 value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool IsEnabled();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabledTimer(Uint16 value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getEnabledTimer();
|
||||
|
||||
// Actualiza el objeto
|
||||
void update();
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void center(int x);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setId(int id);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setIntroEvents(Uint8 *value);
|
||||
|
||||
private:
|
||||
// Posicion X/Y donde empezar a escribir el texto
|
||||
int mPosX;
|
||||
int mPosY;
|
||||
|
||||
// Kerning del texto
|
||||
int mKerning;
|
||||
|
||||
// Texto para escribir
|
||||
std::string mCaption;
|
||||
|
||||
// Velocidad de escritura
|
||||
Uint16 mWrittingSpeed;
|
||||
|
||||
// Temporizador de escritura para cada caracter
|
||||
Uint16 mWrittingTimer;
|
||||
|
||||
// Posición del texto que se está escribiendo
|
||||
Uint16 mIndex;
|
||||
|
||||
// Longitud de la cadena a escribir
|
||||
Uint16 mLenght;
|
||||
|
||||
// Indica si se ha escrito todo el texto
|
||||
bool mWrittingCompleted;
|
||||
|
||||
// Indica si el objeto está habilitado
|
||||
bool mEnabled;
|
||||
|
||||
// Temporizador para deshabilitar el objeto
|
||||
Uint16 mEnabledTimer;
|
||||
|
||||
// Identificador
|
||||
int mId;
|
||||
|
||||
// Dirección del array de eventos donde notificar el estado
|
||||
Uint8 *mIntroEvents;
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
|
||||
#ifndef WRITER_H
|
||||
#define WRITER_H
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Writer
|
||||
{
|
||||
private:
|
||||
int mPosX; // Posicion en el eje X donde empezar a escribir el texto
|
||||
int mPosY; // Posicion en el eje Y donde empezar a escribir el texto
|
||||
int mKerning; // Kerning del texto, es decir, espaciado entre caracteres
|
||||
std::string mCaption; // El texto para escribir
|
||||
Uint16 mSpeed; // Velocidad de escritura
|
||||
Uint16 mTimer; // Temporizador de escritura para cada caracter
|
||||
Uint16 mIndex; // Posición del texto que se está escribiendo
|
||||
Uint16 mLenght; // Longitud de la cadena a escribir
|
||||
bool mCompleted; // Indica si se ha escrito todo el texto
|
||||
bool mEnabled; // Indica si el objeto está habilitado
|
||||
Uint16 mEnabledTimer; // Temporizador para deshabilitar el objeto
|
||||
int mId; // Temporizador para deshabilitar el objeto
|
||||
Uint8 *mIntroEvents; // Dirección del array de eventos donde notificar el estado
|
||||
Text *mText; // Objeto encargado de escribir el texto
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Writer(Text *text);
|
||||
|
||||
// Destructor
|
||||
~Writer();
|
||||
|
||||
// Inicializador
|
||||
void init();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setKerning(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setCaption(std::string text);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setSpeed(Uint16 value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool IsEnabled();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabledTimer(Uint16 value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getEnabledTimer();
|
||||
|
||||
// Actualiza el objeto
|
||||
void update();
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void center(int x);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setId(int id);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setIntroEvents(Uint8 *value);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user