Ja es mouen els sprites en hiscore_table.cpp, falta decidir-se per un disseny concret
This commit is contained in:
@@ -53,9 +53,6 @@ HiScoreTable::HiScoreTable()
|
||||
|
||||
// Crea los sprites con los textos
|
||||
createSprites();
|
||||
|
||||
// Crea el contenido de la textura con la lista de puntuaciones
|
||||
fillTexture();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -80,6 +77,9 @@ void HiScoreTable::update()
|
||||
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
||||
}
|
||||
|
||||
// Actualiza las posiciones de los sprites de texto
|
||||
updateSprites();
|
||||
|
||||
// Actualiza el objeto screen
|
||||
Screen::get()->update();
|
||||
|
||||
@@ -105,10 +105,13 @@ void HiScoreTable::update()
|
||||
{
|
||||
fade_->activate();
|
||||
}
|
||||
|
||||
// Dibuja los sprites en la textura
|
||||
fillTexture();
|
||||
}
|
||||
}
|
||||
|
||||
// Crea el contenido de la textura con la lista de puntuaciones
|
||||
// Dibuja los sprites en la textura
|
||||
void HiScoreTable::fillTexture()
|
||||
{
|
||||
// Pinta en el backbuffer el texto y los sprites
|
||||
@@ -265,6 +268,11 @@ std::string HiScoreTable::format(int number)
|
||||
// Crea los sprites con los textos
|
||||
void HiScoreTable::createSprites()
|
||||
{
|
||||
// Obtiene el tamaño de la textura
|
||||
int backbuffer_width;
|
||||
int backbuffer_height;
|
||||
SDL_QueryTexture(backbuffer_, nullptr, nullptr, &backbuffer_width, &backbuffer_height);
|
||||
|
||||
// Hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots
|
||||
constexpr int max_names = 10;
|
||||
constexpr int space_between_header = 32;
|
||||
@@ -291,6 +299,68 @@ void HiScoreTable::createSprites()
|
||||
const auto line = options.game.hi_score_table.at(i).name + dots + score;
|
||||
|
||||
entry_names_.emplace_back(std::make_shared<PathSprite>(text_->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color)));
|
||||
entry_names_.back()->setPosition(param.game.game_area.center_x - (entry_names_.back()->getWidth() / 2), (i * space_between_lines) + first_line + space_between_header);
|
||||
if (false)
|
||||
{
|
||||
if (i % 1 == 0)
|
||||
{
|
||||
entry_names_.back()->addPath(
|
||||
-entry_names_.back()->getWidth(),
|
||||
(backbuffer_width - entry_names_.back()->getWidth()) / 2,
|
||||
PathType::HORIZONTAL,
|
||||
(i * space_between_lines) + first_line + space_between_header,
|
||||
80,
|
||||
easeOutQuint,
|
||||
0);
|
||||
entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_names_.back()->addPath(
|
||||
backbuffer_width,
|
||||
(backbuffer_width - entry_names_.back()->getWidth()) / 2,
|
||||
PathType::HORIZONTAL,
|
||||
(i * space_between_lines) + first_line + space_between_header,
|
||||
80,
|
||||
easeOutQuint,
|
||||
0);
|
||||
entry_names_.back()->setPosition(backbuffer_width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
entry_names_.back()->addPath(
|
||||
backbuffer_height,
|
||||
(i * space_between_lines) + first_line + space_between_header,
|
||||
PathType::VERTICAL,
|
||||
(backbuffer_width - entry_names_.back()->getWidth()) / 2,
|
||||
80,
|
||||
easeOutQuint,
|
||||
0);
|
||||
entry_names_.back()->setPosition(0, backbuffer_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las posiciones de los sprites de texto
|
||||
void HiScoreTable::updateSprites()
|
||||
{
|
||||
constexpr int init_counter = 220;
|
||||
const int counter_between_entries = text_->getCharacterSize() * 2;
|
||||
if (counter_ >= init_counter)
|
||||
{
|
||||
const int counter2 = counter_ - init_counter;
|
||||
if (counter2 % counter_between_entries == 0)
|
||||
{
|
||||
int index = counter2 / counter_between_entries;
|
||||
if (index < static_cast<int>(entry_names_.size()))
|
||||
{
|
||||
entry_names_.at(index)->enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto const &entry : entry_names_)
|
||||
{
|
||||
entry->update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user