El game_text dels items ja son textures generades i precarregades
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "asset.h" // Para Asset, AssetType
|
||||
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text
|
||||
struct JA_Music_t;
|
||||
struct JA_Sound_t;
|
||||
|
||||
@@ -40,19 +41,10 @@ Resource::Resource()
|
||||
loadAnimations();
|
||||
loadDemoData();
|
||||
addPalettes();
|
||||
createTextures();
|
||||
std::cout << "\n** RESOURCES LOADED" << std::endl;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Resource::~Resource()
|
||||
{
|
||||
sounds_.clear();
|
||||
musics_.clear();
|
||||
textures_.clear();
|
||||
text_files_.clear();
|
||||
animations_.clear();
|
||||
}
|
||||
|
||||
// Obtiene el sonido a partir de un nombre
|
||||
JA_Sound_t *Resource::getSound(const std::string &name)
|
||||
{
|
||||
@@ -230,4 +222,35 @@ void Resource::addPalettes()
|
||||
|
||||
// Fuentes
|
||||
getTexture("smb2.gif")->addPaletteFromFile(Asset::get()->get("smb2_palette1.pal"));
|
||||
}
|
||||
}
|
||||
|
||||
// Crea texturas
|
||||
void Resource::createTextures()
|
||||
{
|
||||
struct NameAndText
|
||||
{
|
||||
std::string name;
|
||||
std::string text;
|
||||
|
||||
// Constructor
|
||||
NameAndText(const std::string &name_init, const std::string &text_init)
|
||||
: name(name_init), text(text_init) {}
|
||||
};
|
||||
|
||||
std::vector<NameAndText> strings = {
|
||||
NameAndText("game_text_1000_points", "1.000"),
|
||||
NameAndText("game_text_2500_points", "2.500"),
|
||||
NameAndText("game_text_5000_points", "5.000"),
|
||||
NameAndText("game_text_powerup", "PowerUp"),
|
||||
NameAndText("game_text_one_hit", "+1 Hit"),
|
||||
NameAndText("game_text_stop", "Stop!")};
|
||||
|
||||
auto text = std::make_unique<Text>(getTexture("04b_25.png"), getTextFile("04b_25.txt"));
|
||||
|
||||
std::cout << "\n>> CREATING TEXTURES" << std::endl;
|
||||
for (const auto &s : strings)
|
||||
{
|
||||
textures_.emplace_back(ResourceTexture(s.name, text->writeToTexture(s.text, -2)));
|
||||
printWithDots("Texture : ", s.name, "[ DONE ]");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user