diff --git a/media/font/8bithud.txt b/media/font/8bithud.txt index 830d929..afb8106 100644 --- a/media/font/8bithud.txt +++ b/media/font/8bithud.txt @@ -3,7 +3,7 @@ # box height 8 # 32 espacio ( ) -6 +2 # 33 ! 2 # 34 " @@ -185,9 +185,10 @@ # 122 z 5 # 123 { - +3 # 124 | - +2 # 125 } - -# 126 ~ \ No newline at end of file +3 +# 126 ~ +3 \ No newline at end of file diff --git a/media/font/nokia.txt b/media/font/nokia.txt new file mode 100644 index 0000000..afb8106 --- /dev/null +++ b/media/font/nokia.txt @@ -0,0 +1,194 @@ +# box width +8 +# box height +8 +# 32 espacio ( ) +2 +# 33 ! +2 +# 34 " +5 +# 35 # +6 +# 36 $ +6 +# 37 % +6 +# 38 & +6 +# 39 ' +2 +# 40 ( +3 +# 41 ) +3 +# 42 * +4 +# 43 + +3 +# 44 , +2 +# 45 - +3 +# 46 . +2 +# 47 / +4 +# 48 0 +6 +# 49 1 +3 +# 50 2 +6 +# 51 3 +6 +# 52 4 +6 +# 53 5 +6 +# 54 6 +6 +# 55 7 +6 +# 56 8 +6 +# 57 9 +6 +# 58 : +2 +# 59 ; +2 +# 60 < +4 +# 61 = +3 +# 62 > +4 +# 63 ? +6 +# 64 @ +8 +# 65 A +6 +# 66 B +6 +# 67 C +6 +# 68 D +6 +# 69 E +6 +# 70 F +6 +# 71 G +6 +# 72 H +6 +# 73 I +6 +# 74 J +6 +# 75 K +6 +# 76 L +6 +# 77 M +6 +# 78 N +6 +# 79 O +6 +# 80 P +6 +# 81 Q +6 +# 82 R +6 +# 83 S +6 +# 84 T +6 +# 85 U +6 +# 86 V +5 +# 87 W +6 +# 88 X +6 +# 89 Y +6 +# 90 Z +6 +# 91 [ +3 +# 92 \ +5 +# 93 ] +3 +# 94 ^ +4 +# 95 _ +6 +# 96 ` +2 +# 97 a +5 +# 98 b +5 +# 99 c +5 +# 100 d +5 +# 101 e +5 +# 102 f +5 +# 103 g +5 +# 104 h +5 +# 105 i +4 +# 106 j +5 +# 107 k +5 +# 108 l +5 +# 109 m +6 +# 110 n +5 +# 111 o +5 +# 112 p +5 +# 113 q +5 +# 114 r +5 +# 115 s +5 +# 116 t +4 +# 117 u +5 +# 118 v +5 +# 119 w +6 +# 120 x +4 +# 121 y +4 +# 122 z +5 +# 123 { +3 +# 124 | +2 +# 125 } +3 +# 126 ~ +3 \ No newline at end of file diff --git a/media/font/smb2.txt b/media/font/smb2.txt new file mode 100644 index 0000000..afb8106 --- /dev/null +++ b/media/font/smb2.txt @@ -0,0 +1,194 @@ +# box width +8 +# box height +8 +# 32 espacio ( ) +2 +# 33 ! +2 +# 34 " +5 +# 35 # +6 +# 36 $ +6 +# 37 % +6 +# 38 & +6 +# 39 ' +2 +# 40 ( +3 +# 41 ) +3 +# 42 * +4 +# 43 + +3 +# 44 , +2 +# 45 - +3 +# 46 . +2 +# 47 / +4 +# 48 0 +6 +# 49 1 +3 +# 50 2 +6 +# 51 3 +6 +# 52 4 +6 +# 53 5 +6 +# 54 6 +6 +# 55 7 +6 +# 56 8 +6 +# 57 9 +6 +# 58 : +2 +# 59 ; +2 +# 60 < +4 +# 61 = +3 +# 62 > +4 +# 63 ? +6 +# 64 @ +8 +# 65 A +6 +# 66 B +6 +# 67 C +6 +# 68 D +6 +# 69 E +6 +# 70 F +6 +# 71 G +6 +# 72 H +6 +# 73 I +6 +# 74 J +6 +# 75 K +6 +# 76 L +6 +# 77 M +6 +# 78 N +6 +# 79 O +6 +# 80 P +6 +# 81 Q +6 +# 82 R +6 +# 83 S +6 +# 84 T +6 +# 85 U +6 +# 86 V +5 +# 87 W +6 +# 88 X +6 +# 89 Y +6 +# 90 Z +6 +# 91 [ +3 +# 92 \ +5 +# 93 ] +3 +# 94 ^ +4 +# 95 _ +6 +# 96 ` +2 +# 97 a +5 +# 98 b +5 +# 99 c +5 +# 100 d +5 +# 101 e +5 +# 102 f +5 +# 103 g +5 +# 104 h +5 +# 105 i +4 +# 106 j +5 +# 107 k +5 +# 108 l +5 +# 109 m +6 +# 110 n +5 +# 111 o +5 +# 112 p +5 +# 113 q +5 +# 114 r +5 +# 115 s +5 +# 116 t +4 +# 117 u +5 +# 118 v +5 +# 119 w +6 +# 120 x +4 +# 121 y +4 +# 122 z +5 +# 123 { +3 +# 124 | +2 +# 125 } +3 +# 126 ~ +3 \ No newline at end of file diff --git a/media/font/smb2_big.txt b/media/font/smb2_big.txt new file mode 100644 index 0000000..afb8106 --- /dev/null +++ b/media/font/smb2_big.txt @@ -0,0 +1,194 @@ +# box width +8 +# box height +8 +# 32 espacio ( ) +2 +# 33 ! +2 +# 34 " +5 +# 35 # +6 +# 36 $ +6 +# 37 % +6 +# 38 & +6 +# 39 ' +2 +# 40 ( +3 +# 41 ) +3 +# 42 * +4 +# 43 + +3 +# 44 , +2 +# 45 - +3 +# 46 . +2 +# 47 / +4 +# 48 0 +6 +# 49 1 +3 +# 50 2 +6 +# 51 3 +6 +# 52 4 +6 +# 53 5 +6 +# 54 6 +6 +# 55 7 +6 +# 56 8 +6 +# 57 9 +6 +# 58 : +2 +# 59 ; +2 +# 60 < +4 +# 61 = +3 +# 62 > +4 +# 63 ? +6 +# 64 @ +8 +# 65 A +6 +# 66 B +6 +# 67 C +6 +# 68 D +6 +# 69 E +6 +# 70 F +6 +# 71 G +6 +# 72 H +6 +# 73 I +6 +# 74 J +6 +# 75 K +6 +# 76 L +6 +# 77 M +6 +# 78 N +6 +# 79 O +6 +# 80 P +6 +# 81 Q +6 +# 82 R +6 +# 83 S +6 +# 84 T +6 +# 85 U +6 +# 86 V +5 +# 87 W +6 +# 88 X +6 +# 89 Y +6 +# 90 Z +6 +# 91 [ +3 +# 92 \ +5 +# 93 ] +3 +# 94 ^ +4 +# 95 _ +6 +# 96 ` +2 +# 97 a +5 +# 98 b +5 +# 99 c +5 +# 100 d +5 +# 101 e +5 +# 102 f +5 +# 103 g +5 +# 104 h +5 +# 105 i +4 +# 106 j +5 +# 107 k +5 +# 108 l +5 +# 109 m +6 +# 110 n +5 +# 111 o +5 +# 112 p +5 +# 113 q +5 +# 114 r +5 +# 115 s +5 +# 116 t +4 +# 117 u +5 +# 118 v +5 +# 119 w +6 +# 120 x +4 +# 121 y +4 +# 122 z +5 +# 123 { +3 +# 124 | +2 +# 125 } +3 +# 126 ~ +3 \ No newline at end of file diff --git a/source/director.cpp b/source/director.cpp index ff38916..edd8fd8 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -236,7 +236,9 @@ void Director::setFileList() mFileList[46] = mExecutablePath + "/" + "../media/font/8bithud.txt"; mFileList[28] = mExecutablePath + "/" + "../media/font/nokia.png"; mFileList[29] = mExecutablePath + "/" + "../media/font/smb2_big.png"; + mFileList[47] = mExecutablePath + "/" + "../media/font/smb2_big.txt"; mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png"; + mFileList[48] = mExecutablePath + "/" + "../media/font/smb2.txt"; } // Comprueba que todos los ficheros existen diff --git a/source/game.cpp b/source/game.cpp index cabb45a..ee28c62 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -42,10 +42,12 @@ Game::Game(int numPlayers, SDL_Renderer *renderer, std::string *filelist, std::s mTexturePlayer2Death = new LTexture(); mTexturePlayer2Legs = new LTexture(); mTextureText = new LTexture(); - mTextureText2 = new LTexture(); + mTextureTextScoreBoard = new LTexture(); + mTextureTextBig = new LTexture(); - mText = new Text(mFileList[46], mTextureText, mRenderer); - mTextX2 = new Text(mFileList[46], mTextureText2, mRenderer); + mText = new Text(mFileList[48], mTextureText, mRenderer); + mTextScoreBoard = new Text(mFileList[46], mTextureTextScoreBoard, mRenderer); + mTextBig = new Text(mFileList[47], mTextureTextBig, mRenderer); mMenuGameOver = new Menu(mRenderer, mText, mInput[0], mFileList); mMenuPause = new Menu(mRenderer, mText, mInput[0], mFileList); @@ -169,15 +171,22 @@ Game::~Game() delete mTextureText; mTextureText = nullptr; - mTextureText2->unload(); - delete mTextureText2; - mTextureText2 = nullptr; + mTextureTextScoreBoard->unload(); + delete mTextureTextScoreBoard; + mTextureTextScoreBoard = nullptr; + + mTextureTextBig->unload(); + delete mTextureTextBig; + mTextureTextBig = nullptr; delete mText; mText = nullptr; - delete mTextX2; - mTextX2 = nullptr; + delete mTextScoreBoard; + mTextScoreBoard = nullptr; + + delete mTextureTextBig; + mTextureTextBig = nullptr; delete mMenuGameOver; mMenuGameOver = nullptr; @@ -345,7 +354,8 @@ void Game::init() // Inicializa los objetos de texto mText->init(); - mTextX2->init(); + mTextScoreBoard->init(); + mTextBig->init(); // Inicializa el objeto con el menu de pausa mMenuPause->init("PAUSE", 0, 12 * BLOCK, MENU_BACKGROUND_SOLID); @@ -485,8 +495,9 @@ bool Game::loadMedia() bool success = true; // Texturas - success &= loadTextureFromFile(mTextureText, mFileList[27], mRenderer); - success &= loadTextureFromFile(mTextureText2, mFileList[29], mRenderer); + success &= loadTextureFromFile(mTextureText, mFileList[30], mRenderer); + success &= loadTextureFromFile(mTextureTextScoreBoard, mFileList[27], mRenderer); + success &= loadTextureFromFile(mTextureTextBig, mFileList[29], mRenderer); success &= loadTextureFromFile(mTexturePlayer1Legs, mFileList[39], mRenderer); success &= loadTextureFromFile(mTexturePlayer1Head, mFileList[41], mRenderer); @@ -1581,41 +1592,38 @@ void Game::renderScoreBoard() mSpritePowerMeter->setSpriteClip(296, 184, (int)percent, 8); mSpritePowerMeter->render(); */ - const int offset1 = 163; + const int offset1 = 162; const int offset2 = offset1 + 7; const int offset3 = offset2 + 7; const int offset4 = offset3 + 7; // PLAYER1 - SCORE - mText->write(PLAY_AREA_LEFT, offset1, mTextStrings[53], 0); - mText->write(PLAY_AREA_LEFT, offset2, updateScoreText(mPlayer[0]->getScore()), 0); + mTextScoreBoard->writeCentered(49/2, offset1, mTextStrings[53]); + mTextScoreBoard->write(PLAY_AREA_LEFT+1, offset2, updateScoreText(mPlayer[0]->getScore())); // PLAYER1 - MULT - mText->write(PLAY_AREA_LEFT, offset3, mTextStrings[55], 0); - mText->write(PLAY_AREA_LEFT + (8 * 7), offset3, std::to_string(mPlayer[0]->getScoreMultiplier()), 0); + mTextScoreBoard->write(PLAY_AREA_LEFT+1, offset3, mTextStrings[55] + std::to_string(mPlayer[0]->getScoreMultiplier()).substr(0, 3)); if (mNumPlayers == 2) { // PLAYER2 - SCORE - mText->write(PLAY_AREA_RIGHT - (8 * 8), offset1, mTextStrings[54], 0); - mText->write(PLAY_AREA_RIGHT - (8 * 7), offset2, updateScoreText(mPlayer[1]->getScore()), 0); + mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - (49/2), offset1, mTextStrings[54]); + mTextScoreBoard->write(PLAY_AREA_RIGHT - 49, offset2, updateScoreText(mPlayer[1]->getScore())); // PLAYER2 - MULT - mText->write(PLAY_AREA_RIGHT - (8 * 10), offset3, mTextStrings[55], 0); - mText->write(PLAY_AREA_RIGHT - (8 * 5), offset3, std::to_string(mPlayer[1]->getScoreMultiplier()), 0); + mTextScoreBoard->write(PLAY_AREA_RIGHT - (8 * 10), offset3, mTextStrings[55]+std::to_string(mPlayer[1]->getScoreMultiplier()).substr(0, 3)); } else { // PLAYER2 - SCORE - mText->write(PLAY_AREA_RIGHT - (8 * 9), offset1, mTextStrings[54], 0); - mText->write(PLAY_AREA_RIGHT - (8 * 7), offset2, "0000000", 0); + mTextScoreBoard->writeCentered(PLAY_AREA_RIGHT - (49/2), offset1, mTextStrings[54]); + mTextScoreBoard->write(PLAY_AREA_RIGHT - 49, offset2, "0000000"); // PLAYER2 - MULT - mText->write(PLAY_AREA_RIGHT - (8 * 10), offset3, mTextStrings[55], 0); - mText->write(PLAY_AREA_RIGHT - (8 * 3), offset3, "1.0", 0); + mTextScoreBoard->write(PLAY_AREA_RIGHT - (8 * 10), offset3, mTextStrings[55] + "1.0"); } // STAGE - mText->writeCentered(PLAY_AREA_CENTER_X, offset1, mTextStrings[42] + std::to_string(mStage[mCurrentStage].number), 0); + mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1, mTextStrings[57] + std::to_string(mStage[mCurrentStage].number)); // POWER //mSpritePowerMeter->setSpriteClip(256, 184, 40, 8); @@ -1625,7 +1633,7 @@ void Game::renderScoreBoard() //mSpritePowerMeter->render(); // HI-SCORE - mText->writeCentered(PLAY_AREA_CENTER_X, offset4, mTextStrings[40] + "0000000", 0); + mTextScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, mTextStrings[56] + "0000000"); } // Actualiza las variables del jugador @@ -1804,7 +1812,7 @@ void Game::renderBalloons() { mBalloon[i]->render(); if ((mDebug.enabled) && (mBalloon[i]->isPopping() == false)) - mText->writeCentered(mBalloon[i]->getPosX() + (mBalloon[i]->getWidth() / 2), mBalloon[i]->getPosY() - 8, std::to_string(i), 0); + mText->writeCentered(mBalloon[i]->getPosX() + (mBalloon[i]->getWidth() / 2), mBalloon[i]->getPosY() - 8, std::to_string(i)); } } @@ -2893,7 +2901,7 @@ void Game::renderMessages() { if ((mTimeStoppedCounter > 100) || (mTimeStoppedCounter % 10 > 4)) //mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, "Time Stopped: " + std::to_string(mTimeStoppedCounter / 10)); - mText->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[36] + std::to_string(mTimeStoppedCounter / 10), 0, noColor, 1, shdwTxtColor); + mText->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[36] + std::to_string(mTimeStoppedCounter / 10), 1, noColor, 1, shdwTxtColor); if (mTimeStoppedCounter > 100) { @@ -2910,7 +2918,7 @@ void Game::renderMessages() // D E M O if (mDemo.enabled) if (mDemo.counter % 30 > 14) - mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[37], 0, noColor, 2, shdwTxtColor); + mTextBig->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[37], 0, noColor, 2, shdwTxtColor); // STAGE NUMBER std::string text = mTextStrings[38] + std::to_string(mStage[mCurrentStage].number); @@ -2918,7 +2926,7 @@ void Game::renderMessages() text = mTextStrings[50]; if (mStageBitmapCounter < STAGE_COUNTER) - mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 0, noColor, 2, shdwTxtColor); + mTextBig->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 1, noColor, 2, shdwTxtColor); } // Habilita el efecto del item de detener el tiempo @@ -3243,9 +3251,9 @@ void Game::runGameOverScreen() SDL_RenderClear(mRenderer); // Dibuja los objetos - mTextX2->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mTextStrings[43], 0); - mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mTextStrings[44] + std::to_string(mPlayer[0]->getScore()), 0); - mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y + BLOCK * 2, mTextStrings[45], 0); + mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mTextStrings[43]); + mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mTextStrings[44] + std::to_string(mPlayer[0]->getScore())); + mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y + BLOCK * 2, mTextStrings[45]); mMenuGameOver->render(); mFade->render(); diff --git a/source/game.h b/source/game.h index 9168806..8ae0149 100644 --- a/source/game.h +++ b/source/game.h @@ -85,7 +85,7 @@ private: int mNumPlayers; // Numero de jugadores Player *mPlayer[2]; // Vector con los jugadores jugador - Input *mInput[2]; // Manejador de entrada, uno por cada jugador + Input *mInput[2]; // Manejador de entrada, uno por cada jugador Balloon *mBalloon[MAX_BALLOONS]; // Vector con los objetos globo Bullet *mBullet[MAX_BULLETS]; // Vector con los objetos bala @@ -105,11 +105,13 @@ private: LTexture *mTexturePlayer2Body; // Textura para el cuerpo del jugador2 LTexture *mTexturePlayer2Death; // Textura para la animación de muerte del jugador2 LTexture *mTexturePlayer2Legs; // Textura para las piernas del jugador - LTexture *mTextureText; // Textura para el texto - LTexture *mTextureText2; // Textura para el texto + LTexture *mTextureText; // Textura para el texto del juego + LTexture *mTextureTextScoreBoard; // Textura para el texto del marcador + LTexture *mTextureTextBig; // Textura para el texto grande - Text *mText; // Variable con todos los objetos de texto - Text *mTextX2; // Variable con todos los objetos de texto + Text *mText; // Fuente para los textos del juego + Text *mTextScoreBoard; // Fuente para el marcador del juego + Text *mTextBig; // Fuente de texto grande Menu *mMenuGameOver; // Menú de la pantalla de game over Menu *mMenuPause; // Menú de la pantalla de pausa diff --git a/source/lang.h b/source/lang.h index 86ccd4a..4d29415 100644 --- a/source/lang.h +++ b/source/lang.h @@ -282,26 +282,31 @@ const std::string gTextStrings[MAX_TEXT_STRINGS][3] = // MARCADOR - // 53 - MENU DEL TITULO (2 JUGADORES) + // 53 - JUGADOR 1 {"jugador 1", "jugador 2", "player 1"}, - // 54 - MENU DEL TITULO (2 JUGADORES) + // 54 - JUGADOR 2 {"jugador 2", "jugador 2", "player 2"}, - // 55 - MENU DEL TITULO (2 JUGADORES) + // 55 - MULTIPLICADOR {"mult - ", "mult - ", "mult - "}, - // 56 - MENU DEL TITULO (2 JUGADORES) + // 56 - MAXIMA PUNTUACION {"max. puntuacion - ", "max. puntuacio - ", "high score - "}, + // 57 - FASE + {"fase ", + "nivell ", + "stage "}, + }; void initTextStrings(std::string *textStrings, Uint8 lang); diff --git a/source/menu.cpp b/source/menu.cpp index bdaeb4b..fb825e2 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -291,7 +291,7 @@ void Menu::render() } else { - mText->write(mItem[i].x, mItem[i].y, mItem[i].label, 0); + mText->write(mItem[i].x, mItem[i].y, mItem[i].label); } } } @@ -417,7 +417,7 @@ void Menu::addItem(std::string text, const Uint8 hPaddingUp, const Uint8 hPaddin if (mTotalItems == 0) { mItem[mTotalItems].label = text; - mItem[mTotalItems].w = mText->lenght(mItem[mTotalItems].label, 0); + mItem[mTotalItems].w = mText->lenght(mItem[mTotalItems].label); mItem[mTotalItems].h = mText->getCharacterWidth() + (mVerticalPadding * 2); mItem[mTotalItems].x = mPosX; mItem[mTotalItems].y = mPosY; @@ -430,7 +430,7 @@ void Menu::addItem(std::string text, const Uint8 hPaddingUp, const Uint8 hPaddin if (mTotalItems < 10) { mItem[mTotalItems].label = text; - mItem[mTotalItems].w = mText->lenght(mItem[mTotalItems].label, 0); + mItem[mTotalItems].w = mText->lenght(mItem[mTotalItems].label); mItem[mTotalItems].h = mText->getCharacterWidth() + (mVerticalPadding * 2); mItem[mTotalItems].x = mPosX; mItem[mTotalItems].y = mItem[mTotalItems - 1].y + mItem[mTotalItems - 1].h + mItem[mTotalItems - 1].hPaddingDown; @@ -447,7 +447,7 @@ void Menu::addItem(std::string text, const Uint8 hPaddingUp, const Uint8 hPaddin void Menu::setItemCaption(Uint8 index, std::string text) { mItem[index].label = text; - mItem[index].w = mText->lenght(mItem[index].label, 0); + mItem[index].w = mText->lenght(mItem[index].label); reorganize(); } diff --git a/source/text.cpp b/source/text.cpp index 0afe730..0620952 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -49,8 +49,8 @@ void Text::init() // Establece las coordenadas para cada caracter ascii de la cadena y su ancho for (int i = 32; i < 128; i++) { - mOffset[i].x = ((i - 32) % 16) * mBoxWidth; - mOffset[i].y = ((i - 32) / 16) * mBoxHeight; + mOffset[i].x = ((i - 32) % 15) * mBoxWidth; + mOffset[i].y = ((i - 32) / 15) * mBoxHeight; } } @@ -138,10 +138,12 @@ void Text::initOffsetFromFile() std::getline(rfile, buffer); std::getline(rfile, buffer); mBoxWidth = std::stoi(buffer); + //printf("mBoxWidth: %i\n", mBoxWidth); std::getline(rfile, buffer); std::getline(rfile, buffer); mBoxHeight = std::stoi(buffer); + //printf("mBoxHeight: %i\n", mBoxHeight); // lee el resto de datos del fichero int index = 32; @@ -150,8 +152,10 @@ void Text::initOffsetFromFile() { // Almacena solo las lineas impares if (line_read % 2 == 1) + { + //printf("%i - %i - %s\n", line_read, index, buffer.c_str()); mOffset[index++].w = std::stoi(buffer); - + } //Then clear the buffer once you're done with it. buffer.clear(); line_read++; diff --git a/source/text.h b/source/text.h index 52498c6..ad7ca9c 100644 --- a/source/text.h +++ b/source/text.h @@ -41,22 +41,22 @@ public: void init(); // Escribe el texto en pantalla - void write(int x, int y, std::string text, int kerning = 0, int lenght = -1); + void write(int x, int y, std::string text, int kerning = 1, int lenght = -1); // Escribe el texto con colores - void writeColored(int x, int y, std::string text, color_t color, int kerning = 0, int lenght = -1); + void writeColored(int x, int y, std::string text, color_t color, int kerning = 1, int lenght = -1); // Escribe el texto con sombra - void writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance = 1, int kerning = 0, int lenght = -1); + void writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1); // Escribe el texto centrado en un punto x y con kerning - void writeCentered(int x, int y, std::string text, int kerning = 0, int lenght = -1); + void writeCentered(int x, int y, std::string text, int kerning = 1, int lenght = -1); // Escribe texto con extras - void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 0, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1); + void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1); // Obtiene la longitud en pixels de una cadena - Uint16 lenght(std::string text, int kerning); + Uint16 lenght(std::string text, int kerning = 1); // Devuelve el valor de la variable Uint8 getCharacterWidth();