Ya funcionan las puntuaciones online
This commit is contained in:
@@ -43,19 +43,16 @@ void Notify::update()
|
||||
{
|
||||
notifications.at(i).counter++;
|
||||
|
||||
const int height = notifications.at(i).texture->getHeight();
|
||||
const int halfDesp = text->getCharacterSize() / 2;
|
||||
|
||||
// Comprueba los estados
|
||||
if (notifications.at(i).state == ns_rising)
|
||||
{
|
||||
const float step = ((float)notifications.at(i).counter / (height + halfDesp));
|
||||
const float step = ((float)notifications.at(i).counter / notifications.at(i).travelDist);
|
||||
const int alpha = 255 * step;
|
||||
|
||||
notifications.at(i).rect.y++;
|
||||
notifications.at(i).texture->setAlpha(alpha);
|
||||
|
||||
if (notifications.at(i).rect.y == 0 + halfDesp)
|
||||
if (notifications.at(i).rect.y == notifications.at(i).y)
|
||||
{
|
||||
notifications.at(i).state = ns_stay;
|
||||
notifications.at(i).texture->setAlpha(255);
|
||||
@@ -74,13 +71,13 @@ void Notify::update()
|
||||
else if (notifications.at(i).state == ns_vanishing)
|
||||
{
|
||||
|
||||
const float step = (notifications.at(i).counter / (float)height);
|
||||
const float step = (notifications.at(i).counter / (float)notifications.at(i).travelDist);
|
||||
const int alpha = 255 * (1 - step);
|
||||
|
||||
notifications.at(i).rect.y--;
|
||||
notifications.at(i).texture->setAlpha(alpha);
|
||||
|
||||
if (notifications.at(i).rect.y == -height)
|
||||
if (notifications.at(i).rect.y == notifications.at(i).y - notifications.at(i).travelDist)
|
||||
{
|
||||
notifications.at(i).state = ns_finished;
|
||||
}
|
||||
@@ -112,17 +109,21 @@ void Notify::showText(std::string text)
|
||||
// Crea constantes
|
||||
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
|
||||
const int height = this->text->getCharacterSize() * 2;
|
||||
const int desp = this->text->getCharacterSize();
|
||||
const int halfDesp = desp / 2;
|
||||
const int despH = this->text->getCharacterSize() / 2;
|
||||
const int despV = despH;
|
||||
const int travelDist = height + despV;
|
||||
const int offset = (int)notifications.size() * (travelDist) + despV;
|
||||
|
||||
// Crea la notificacion
|
||||
notification_t n;
|
||||
|
||||
// inicializa variables
|
||||
n.y = offset;
|
||||
n.travelDist = travelDist;
|
||||
n.counter = 0;
|
||||
n.state = ns_rising;
|
||||
n.text = text;
|
||||
n.rect = {halfDesp, -height, width, height};
|
||||
n.rect = {despH, offset - travelDist, width, height};
|
||||
|
||||
// Crea la textura
|
||||
n.texture = new Texture(renderer);
|
||||
@@ -131,7 +132,7 @@ void Notify::showText(std::string text)
|
||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, halfDesp, text, 1, {255, 255, 255}, 1, {0, 0, 0});
|
||||
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, despV, text, 1, {255, 255, 255}, 1, {0, 0, 0});
|
||||
|
||||
// Crea el sprite
|
||||
n.sprite = new Sprite(n.rect, n.texture, renderer);
|
||||
|
||||
Reference in New Issue
Block a user