trabajando los items

This commit is contained in:
2022-10-03 11:45:09 +02:00
parent 9c35fadd55
commit 91b868572e
22 changed files with 266 additions and 194 deletions

View File

@@ -13,7 +13,7 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *mAsset
// Reserva memoria para los punteros
mEventHandler = new SDL_Event();
mItemTexture = new LTexture(mRenderer,mAsset->get("items.png"));
mItemTexture = new LTexture(mRenderer, mAsset->get("items.png"));
mSprite = new Sprite(0, 0, GAME_WIDTH, GAME_HEIGHT, mItemTexture, mRenderer);
mText = new Text(mAsset->get("smb2.png"), mAsset->get("smb2.txt"), mRenderer);
@@ -28,26 +28,14 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *mAsset
// Destructor
Instructions::~Instructions()
{
mRenderer = nullptr;
mScreen = nullptr;
mAsset = nullptr;
mLang = nullptr;
mItemTexture->unload();
delete mItemTexture;
mItemTexture = nullptr;
delete mSprite;
mSprite = nullptr;
delete mEventHandler;
mEventHandler = nullptr;
delete mText;
mText = nullptr;
SDL_DestroyTexture(mBackbuffer);
mBackbuffer = nullptr;
}
// Inicializa las variables necesarias para la sección 'Instructions'
@@ -87,7 +75,9 @@ void Instructions::run(Uint8 mode)
mSection.subsection = TITLE_SECTION_1;
}
else
{
mManualQuit = true;
}
}
}
@@ -97,9 +87,8 @@ void Instructions::run(Uint8 mode)
// Actualiza el contador de ticks
mTicks = SDL_GetTicks();
// Modo automático
if (mode == INSTRUCTIONS_MODE_AUTO)
{
{ // Modo automático
mCounter++;
if (mCounter == INSTRUCTIONS_COUNTER)
@@ -108,9 +97,8 @@ void Instructions::run(Uint8 mode)
mSection.subsection = TITLE_SECTION_1;
}
}
// Modo manual
else
{
{ // Modo manual
++mCounter %= 60000;
if (mManualQuit)
@@ -153,7 +141,9 @@ void Instructions::run(Uint8 mode)
mText->writeShadowed(84, 156, mLang->getText(21), shdwTxtColor);
if ((mode == INSTRUCTIONS_MODE_MANUAL) && (mCounter % 50 > 14))
{
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - 12, mLang->getText(22), 1, orangeColor, 1, shdwTxtColor);
}
// Disquito
mSprite->setPos(destRect1);
@@ -201,9 +191,13 @@ void Instructions::run(Uint8 mode)
// Establece la ventana del backbuffer
if (mode == INSTRUCTIONS_MODE_AUTO)
{
window.y = std::max(8, GAME_HEIGHT - mCounter + 100);
}
else
{
window.y = 0;
}
// Copia el backbuffer al renderizador
SDL_RenderCopy(mRenderer, mBackbuffer, nullptr, &window);