diff --git a/data/gfx/title.png b/data/gfx/title.png deleted file mode 100644 index d6a3a17..0000000 Binary files a/data/gfx/title.png and /dev/null differ diff --git a/data/gfx/title_bg_tile.png b/data/gfx/title_bg_tile.png new file mode 100644 index 0000000..6f0ea29 Binary files /dev/null and b/data/gfx/title_bg_tile.png differ diff --git a/data/gfx/title_coffee.png b/data/gfx/title_coffee.png new file mode 100644 index 0000000..1dc74c0 Binary files /dev/null and b/data/gfx/title_coffee.png differ diff --git a/data/gfx/title_crisis.png b/data/gfx/title_crisis.png new file mode 100644 index 0000000..be75692 Binary files /dev/null and b/data/gfx/title_crisis.png differ diff --git a/data/gfx/title_dust.ani b/data/gfx/title_dust.ani new file mode 100644 index 0000000..9e655a4 --- /dev/null +++ b/data/gfx/title_dust.ani @@ -0,0 +1,9 @@ +frameWidth=16 +frameHeight=16 + +[animation] +name=default +speed=8 +loop=-1 +frames=0,1,2,3,4,5,6 +[/animation] \ No newline at end of file diff --git a/data/gfx/title_dust.png b/data/gfx/title_dust.png new file mode 100644 index 0000000..3d4a967 Binary files /dev/null and b/data/gfx/title_dust.png differ diff --git a/data/gfx/title_gradient.png b/data/gfx/title_gradient.png new file mode 100644 index 0000000..046b5aa Binary files /dev/null and b/data/gfx/title_gradient.png differ diff --git a/data/menu/options.men b/data/menu/options.men new file mode 100644 index 0000000..010badc --- /dev/null +++ b/data/menu/options.men @@ -0,0 +1,109 @@ +font_png=smb2.png +font_txt=smb2.txt + +sound_cancel=menu_cancel.wav +sound_accept=menu_select.wav +sound_move=menu_move.wav + +name=TITLE +x=0 +y=116 +backgroundType=0 +backgroundColor=48,48,64,192 + +areElementsCenteredOnX=true + +isCenteredOnX=true +centerX=128 + +isCenteredOnY=true +centerY=96 + +selector_color=229,28,35,0 +selector_text_color=255,180,0 + +defaultActionWhenCancel=13 + +[item] +text=DIFFICULTY +hPaddingDown=7 +[/item] + +[item] +text=PLAYER 1 CONTROLS +hPaddingDown=2 +selectable=true +greyed=false +linkedDown=true +[/item] + +[item] +text=KEYBOARD +hPaddingDown=7 +selectable=false +greyed=false +[/item] + +[item] +text=PLAYER 2 CONTROLS +hPaddingDown=2 +selectable=true +greyed=false +linkedDown=true +[/item] + +[item] +text=GAME CONTROLLER +hPaddingDown=7 +selectable=false +greyed=false +[/item] + +[item] +text=LANGUAGE +hPaddingDown=7 +[/item] + +[item] +text=DISPLAY MODE +hPaddingDown=2 +selectable=true +greyed=false +linkedDown=true +[/item] + +[item] +text=WINDOW +hPaddingDown=7 +selectable=false +greyed=false +[/item] + +[item] +text=WINDOW SIZE +hPaddingDown=2 +[/item] + +[item] +text=FILTER +hPaddingDown=2 +[/item] + +[item] +text=VSYNC +hPaddingDown=7 +[/item] + +[item] +text=HOW TO PLAY +hPaddingDown=7 +[/item] + +[item] +text=ACCEPT +hPaddingDown=2 +[/item] + +[item] +text=CANCEL +[/item] \ No newline at end of file diff --git a/data/menu/title.men b/data/menu/title.men new file mode 100644 index 0000000..5d87cb4 --- /dev/null +++ b/data/menu/title.men @@ -0,0 +1,40 @@ +font_png=smb2.png +font_txt=smb2.txt + +sound_cancel=menu_cancel.wav +sound_accept=menu_select.wav +sound_move=menu_move.wav + +name=TITLE +x=0 +y=116 +backgroundType=0 +backgroundColor=48,48,64,192 + +areElementsCenteredOnX=true +isCenteredOnX=true +centerX=128 + +selector_color=229,28,35,0 +selector_text_color=255,180,0 + +defaultActionWhenCancel=3 + +[item] +text=1 PLAYER +hPaddingDown=2 +[/item] + +[item] +text=2 PLAYERS +hPaddingDown=7 +[/item] + +[item] +text=OPTIONS +hPaddingDown=7 +[/item] + +[item] +text=QUIT +[/item] \ No newline at end of file diff --git a/source/director.cpp b/source/director.cpp index 42aefe8..05e212d 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -196,15 +196,23 @@ bool Director::setFileList() asset->add("data/gfx/intro.png", t_bitmap); asset->add("data/gfx/items.png", t_bitmap); asset->add("data/gfx/logo.png", t_bitmap); - asset->add("data/gfx/player1_body.png", t_bitmap); - asset->add("data/gfx/player1_death.png", t_bitmap); - asset->add("data/gfx/player1_legs.png", t_bitmap); - asset->add("data/gfx/title.png", t_bitmap); + + asset->add("data/gfx/title_bg_tile.png", t_bitmap); + asset->add("data/gfx/title_coffee.png", t_bitmap); + asset->add("data/gfx/title_crisis.png", t_bitmap); + asset->add("data/gfx/title_dust.png", t_bitmap); + asset->add("data/gfx/title_dust.ani", t_data); + asset->add("data/gfx/title_gradient.png", t_bitmap); + asset->add("data/gfx/player1_head.png", t_bitmap); - asset->add("data/gfx/player2_body.png", t_bitmap); - asset->add("data/gfx/player2_death.png", t_bitmap); - asset->add("data/gfx/player2_legs.png", t_bitmap); + asset->add("data/gfx/player1_body.png", t_bitmap); + asset->add("data/gfx/player1_legs.png", t_bitmap); + asset->add("data/gfx/player1_death.png", t_bitmap); + asset->add("data/gfx/player2_head.png", t_bitmap); + asset->add("data/gfx/player2_body.png", t_bitmap); + asset->add("data/gfx/player2_legs.png", t_bitmap); + asset->add("data/gfx/player2_death.png", t_bitmap); // Fuentes asset->add("data/font/8bithud.png", t_font); @@ -225,6 +233,11 @@ bool Director::setFileList() asset->add("data/lang/en_UK.txt", t_lang); asset->add("data/lang/ba_BA.txt", t_lang); + // Menus + asset->add("data/menu/title.men", t_data); + asset->add("data/menu/options.men", t_data); + + return asset->check(); } diff --git a/source/menu.cpp b/source/menu.cpp index 8adcecc..2513492 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -4,16 +4,55 @@ // Constructor Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) { + // Copia punteros this->renderer = renderer; this->asset = asset; this->input = input; + // Inicializa punteros soundMove = nullptr; soundAccept = nullptr; soundCancel = nullptr; - init(); + // Inicializa variables + name = ""; + selector.index = 0; + itemSelected = MENU_NO_OPTION; + x = 0; + y = 0; + rectBG.rect = {0, 0, 0, 0}; + rectBG.color = {0, 0, 0}; + rectBG.a = 0; + backgroundType = MENU_BACKGROUND_SOLID; + isCenteredOnX = false; + isCenteredOnY = false; + areElementsCenteredOnX = false; + centerX = 0; + centerY = 0; + widestItem = 0; + colorGreyed = {128, 128, 128}; + defaultActionWhenCancel = 0; + font_png = ""; + font_txt = ""; + // Selector + selector.originY = 0; + selector.targetY = 0; + selector.despY = 0; + selector.originH = 0; + selector.targetH = 0; + selector.incH = 0; + selector.y = 0.0f; + selector.h = 0.0f; + selector.numJumps = 8; + selector.moving = false; + selector.resizing = false; + selector.rect = {0, 0, 0, 0}; + selector.color = {0, 0, 0}; + selector.itemColor = {0, 0, 0}; + selector.a = 255; + + // Inicializa las variables desde un fichero if (file != "") { load(file); @@ -129,7 +168,7 @@ bool Menu::load(std::string file_path) } // Reorganiza el menu con los valores recien cargados - //reorganize(); + // reorganize(); return success; } @@ -315,43 +354,6 @@ bool Menu::setVars(std::string var, std::string value) // Inicializa las variables void Menu::init() { - // Inicia variables - name = ""; - selector.index = 0; - itemSelected = MENU_NO_OPTION; - x = 0; - y = 0; - rectBG.rect = {0, 0, 0, 0}; - rectBG.color = {0, 0, 0}; - rectBG.a = 0; - backgroundType = MENU_BACKGROUND_SOLID; - isCenteredOnX = false; - isCenteredOnY = false; - areElementsCenteredOnX = false; - centerX = 0; - centerY = 0; - widestItem = 0; - colorGreyed = {128, 128, 128}; - defaultActionWhenCancel = 0; - font_png = ""; - font_txt = ""; - - // Selector - selector.originY = 0; - selector.targetY = 0; - selector.despY = 0; - selector.originH = 0; - selector.targetH = 0; - selector.incH = 0; - selector.y = 0.0f; - selector.h = 0.0f; - selector.numJumps = 8; - selector.moving = false; - selector.resizing = false; - selector.rect = {0, 0, 0, 0}; - selector.color = {0, 0, 0}; - selector.itemColor = {0, 0, 0}; - selector.a = 255; } // Carga los ficheros de audio @@ -736,14 +738,13 @@ void Menu::centerMenuElementsOnX() void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool greyed, bool linkedDown) { item_t temp; - // Si es el primer item coge la posición en el eje Y del propio menu + if (item.size() == 0) - { + {// Si es el primer item coge la posición en el eje Y del propio menu temp.rect.y = y; } else - // En caso contrario, coge la posición en el eje Y a partir del elemento anterior - { + {// En caso contrario, coge la posición en el eje Y a partir del elemento anterior temp.rect.y = item.back().rect.y + item.back().rect.h + item.back().hPaddingDown; } @@ -754,6 +755,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre temp.linkedDown = linkedDown; item.push_back(temp); + setItemCaption(item.size() - 1, text); if (item.size() > 0) diff --git a/source/title.cpp b/source/title.cpp index 99b530a..986529b 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -15,28 +15,22 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, mEventHandler = new SDL_Event(); mFade = new Fade(renderer); - mTitleTexture = new LTexture(mRenderer, mAsset->get("title.png")); - mItemsTexture = new LTexture(mRenderer, mAsset->get("items.png")); + dustTexture = new LTexture(mRenderer, mAsset->get("title_dust.png")); + coffeeTexture = new LTexture(mRenderer, mAsset->get("title_coffee.png")); + crisisTexture = new LTexture(mRenderer, mAsset->get("title_crisis.png")); + gradientTexture = new LTexture(mRenderer, mAsset->get("title_gradient.png")); - mCoffeeBitmap = new SmartSprite(mTitleTexture, mRenderer); - mCrisisBitmap = new SmartSprite(mTitleTexture, mRenderer); - mDustBitmapL = new AnimatedSprite(mTitleTexture, mRenderer); - mDustBitmapR = new AnimatedSprite(mTitleTexture, mRenderer); + mCoffeeBitmap = new SmartSprite(coffeeTexture, mRenderer); + mCrisisBitmap = new SmartSprite(crisisTexture, mRenderer); + mDustBitmapL = new AnimatedSprite(dustTexture, mRenderer, mAsset->get("title_dust.ani")); + mDustBitmapR = new AnimatedSprite(dustTexture, mRenderer, mAsset->get("title_dust.ani")); + mGradient = new Sprite({0, 0, 256, 192}, gradientTexture, mRenderer); - mTile = new Sprite({0, 0, 64, 64}, mTitleTexture, mRenderer); - mGradient = new Sprite({0, 0, 256, 192}, mTitleTexture, mRenderer); mText = new Text(mAsset->get("smb2.png"), mAsset->get("smb2.txt"), mRenderer); mText2 = new Text(mAsset->get("8bithud.png"), mAsset->get("8bithud.txt"), mRenderer); - - mMenu.title = new Menu(mRenderer, mAsset, mInput); - mMenu.options = new Menu(mRenderer, mAsset, mInput); - // Crea la textura para el mosaico de fondo - mBackground = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH * 2, GAME_HEIGHT * 2); - if (mBackground == nullptr) - { - printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError()); - } + mMenu.title = new Menu(mRenderer, mAsset, mInput, mAsset->get("title.men")); + mMenu.options = new Menu(mRenderer, mAsset, mInput, mAsset->get("title.men")); // Sonidos mSound = JA_LoadSound(mAsset->get("title.wav").c_str()); @@ -116,45 +110,18 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, mDustBitmapR->setPosX(218); mDustBitmapR->setPosY(47); mDustBitmapR->setWidth(16); - mDustBitmapR->setHeight(14); - mDustBitmapR->setCurrentFrame(0); - mDustBitmapR->setAnimationCounter(0); - mDustBitmapR->setAnimationSpeed(0, 8); - mDustBitmapR->setAnimationLoop(0, false); - mDustBitmapR->setAnimationFrames(0, 0, 160 + (mDustBitmapR->getWidth() * 0), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); - mDustBitmapR->setAnimationFrames(0, 1, 160 + (mDustBitmapR->getWidth() * 1), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); - mDustBitmapR->setAnimationFrames(0, 2, 160 + (mDustBitmapR->getWidth() * 2), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); - mDustBitmapR->setAnimationFrames(0, 3, 160 + (mDustBitmapR->getWidth() * 3), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); - mDustBitmapR->setAnimationFrames(0, 4, 160 + (mDustBitmapR->getWidth() * 4), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); - mDustBitmapR->setAnimationFrames(0, 5, 160 + (mDustBitmapR->getWidth() * 5), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); - mDustBitmapR->setAnimationFrames(0, 6, 160 + (mDustBitmapR->getWidth() * 6), 80, mDustBitmapR->getWidth(), mDustBitmapR->getHeight()); + mDustBitmapR->setHeight(16); + mDustBitmapR->setFlip(SDL_FLIP_HORIZONTAL); // Inicializa el bitmap de DustLeft mDustBitmapL->setPosX(33); mDustBitmapL->setPosY(47); mDustBitmapL->setWidth(16); - mDustBitmapL->setHeight(14); - mDustBitmapL->setCurrentFrame(0); - mDustBitmapL->setAnimationCounter(0); - mDustBitmapL->setAnimationSpeed(0, 8); - mDustBitmapL->setAnimationLoop(0, false); - mDustBitmapL->setAnimationFrames(0, 0, 160 + (mDustBitmapL->getWidth() * 0), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); - mDustBitmapL->setAnimationFrames(0, 1, 160 + (mDustBitmapL->getWidth() * 1), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); - mDustBitmapL->setAnimationFrames(0, 2, 160 + (mDustBitmapL->getWidth() * 2), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); - mDustBitmapL->setAnimationFrames(0, 3, 160 + (mDustBitmapL->getWidth() * 3), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); - mDustBitmapL->setAnimationFrames(0, 4, 160 + (mDustBitmapL->getWidth() * 4), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); - mDustBitmapL->setAnimationFrames(0, 5, 160 + (mDustBitmapL->getWidth() * 5), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); - mDustBitmapL->setAnimationFrames(0, 6, 160 + (mDustBitmapL->getWidth() * 6), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); + mDustBitmapL->setHeight(16); // Inicializa el sprite con el degradado mGradient->setSpriteClip(0, 96, 256, 192); - // Inicializa el vector de eventos de la pantalla de titulo - for (int i = 0; i < TITLE_TOTAL_EVENTS; i++) - { - mEvents[i] = 0;//EVENT_WAITING; - } - // Crea el mosaico de fondo del titulo createTiledBackground(); @@ -171,69 +138,77 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, } // Inicializa los objetos de menu - mMenu.title->setText(mAsset->get("smb2.png"), mAsset->get("smb2.txt")); - mMenu.title->setName("TITLE"); - mMenu.title->setPos(0, (14 * BLOCK) + 4); - mMenu.title->setBackgroundType(MENU_BACKGROUND_TRANSPARENT); - mMenu.title->addItem(mLang->getText(51), 2); // 1 PLAYER - mMenu.title->addItem(mLang->getText(52), 7); // 2 PLAYERS - mMenu.title->addItem(mLang->getText(1), 7); // OPTIONS - mMenu.title->addItem(mLang->getText(3)); // QUIT - mMenu.title->setDefaultActionWhenCancel(3); - mMenu.title->setBackgroundColor({0x30, 0x30, 0x40}, 192); - mMenu.title->setSelectorColor({0xe5, 0x1c, 0x23}, 0); - mMenu.title->setSelectorTextColor({0xFF, 0xB4, 0x00}); - mMenu.title->centerMenuOnX(SCREEN_CENTER_X); - mMenu.title->centerMenuElementsOnX(); + //mMenu.title->setText(mAsset->get("smb2.png"), mAsset->get("smb2.txt")); + //mMenu.title->setName("TITLE"); + //mMenu.title->setPos(0, (14 * BLOCK) + 4); + //mMenu.title->setBackgroundType(MENU_BACKGROUND_TRANSPARENT); + //mMenu.title->addItem(mLang->getText(51), 2); // 1 PLAYER + //mMenu.title->addItem(mLang->getText(52), 7); // 2 PLAYERS + //mMenu.title->addItem(mLang->getText(1), 7); // OPTIONS + //mMenu.title->addItem(mLang->getText(3)); // QUIT + //mMenu.title->setDefaultActionWhenCancel(3); + //mMenu.title->setBackgroundColor({0x30, 0x30, 0x40}, 192); + //mMenu.title->setSelectorColor({0xe5, 0x1c, 0x23}, 0); + //mMenu.title->setSelectorTextColor({0xFF, 0xB4, 0x00}); + //mMenu.title->centerMenuOnX(SCREEN_CENTER_X); + //mMenu.title->centerMenuElementsOnX(); - mMenu.options->setText(mAsset->get("smb2.png"), mAsset->get("smb2.txt")); - mMenu.options->setName("OPTIONS"); - mMenu.options->setPos(0, BLOCK); - mMenu.options->setBackgroundType(MENU_BACKGROUND_TRANSPARENT); - mMenu.options->addItem(mLang->getText(59), 7); // (0) DIFFICULTY - mMenu.options->addItem(mLang->getText(62), 2, true, false, true); // (1) PLAYER 1 CONTROLS - mMenu.options->addItem(mLang->getText(69), 7, false, false); // (2) KEYBOARD - mMenu.options->addItem(mLang->getText(63), 2, true, false, true); // (3) PLAYER 2 CONTROLS - mMenu.options->addItem(mLang->getText(70), 7, false, false); // (4) GAME CONTROLLER - mMenu.options->addItem(mLang->getText(8), 7); // (5) LANGUAGE - mMenu.options->addItem(mLang->getText(58), 2, true, false, true); // (6) DISPLAY MODE - mMenu.options->addItem(mLang->getText(4), 7, false, false); // (7) WINDOW - mMenu.options->addItem(mLang->getText(7), 2); // (8) WINDOW SIZE - mMenu.options->addItem(mLang->getText(60), 2); // (9) FILTER - mMenu.options->addItem(mLang->getText(61), 7); // (10) VSYNC - mMenu.options->addItem(mLang->getText(2), 7); // (11) HOW TO PLAY - mMenu.options->addItem(mLang->getText(9), 2); // (12) ACCEPT - mMenu.options->addItem(mLang->getText(10)); // (13) CANCEL - mMenu.options->setDefaultActionWhenCancel(13); - mMenu.options->setBackgroundColor({0x30, 0x30, 0x40}, 192); - mMenu.options->setSelectorColor({0xe5, 0x1c, 0x23}, 255); - mMenu.options->setSelectorTextColor({0xFF, 0xF1, 0x76}); - mMenu.options->centerMenuOnX(SCREEN_CENTER_X); - mMenu.options->centerMenuOnY(SCREEN_CENTER_Y); + //mMenu.options->setText(mAsset->get("smb2.png"), mAsset->get("smb2.txt")); + //mMenu.options->setName("OPTIONS"); + //mMenu.options->setPos(0, BLOCK); + //mMenu.options->setBackgroundType(MENU_BACKGROUND_TRANSPARENT); + //mMenu.options->addItem(mLang->getText(59), 7); // (0) DIFFICULTY + //mMenu.options->addItem(mLang->getText(62), 2, true, false, true); // (1) PLAYER 1 CONTROLS + //mMenu.options->addItem(mLang->getText(69), 7, false, false); // (2) KEYBOARD + //mMenu.options->addItem(mLang->getText(63), 2, true, false, true); // (3) PLAYER 2 CONTROLS + //mMenu.options->addItem(mLang->getText(70), 7, false, false); // (4) GAME CONTROLLER + //mMenu.options->addItem(mLang->getText(8), 7); // (5) LANGUAGE + //mMenu.options->addItem(mLang->getText(58), 2, true, false, true); // (6) DISPLAY MODE + //mMenu.options->addItem(mLang->getText(4), 7, false, false); // (7) WINDOW + //mMenu.options->addItem(mLang->getText(7), 2); // (8) WINDOW SIZE + //mMenu.options->addItem(mLang->getText(60), 2); // (9) FILTER + //mMenu.options->addItem(mLang->getText(61), 7); // (10) VSYNC + //mMenu.options->addItem(mLang->getText(2), 7); // (11) HOW TO PLAY + //mMenu.options->addItem(mLang->getText(9), 2); // (12) ACCEPT + //mMenu.options->addItem(mLang->getText(10)); // (13) CANCEL + //mMenu.options->setDefaultActionWhenCancel(13); + //mMenu.options->setBackgroundColor({0x30, 0x30, 0x40}, 192); + //mMenu.options->setSelectorColor({0xe5, 0x1c, 0x23}, 255); + //mMenu.options->setSelectorTextColor({0xFF, 0xF1, 0x76}); + //mMenu.options->centerMenuOnX(SCREEN_CENTER_X); + //mMenu.options->centerMenuOnY(SCREEN_CENTER_Y); // Actualiza los textos de los menus - updateMenuLabels(); + //updateMenuLabels(); } // Destructor Title::~Title() { - mTitleTexture->unload(); - delete mTitleTexture; - - mItemsTexture->unload(); - delete mItemsTexture; - delete mEventHandler; - delete mText; - delete mText2; delete mFade; + + dustTexture->unload(); + delete dustTexture; + + coffeeTexture->unload(); + delete coffeeTexture; + + crisisTexture->unload(); + delete crisisTexture; + + gradientTexture->unload(); + delete gradientTexture; + delete mCoffeeBitmap; delete mCrisisBitmap; delete mDustBitmapL; delete mDustBitmapR; - delete mTile; delete mGradient; + + delete mText; + delete mText2; + delete mMenu.title; delete mMenu.options; @@ -243,6 +218,400 @@ Title::~Title() SDL_DestroyTexture(mBackground); } +// Actualiza las variables del objeto +void Title::update() +{ + // Comprueba los eventos + checkEventHandler(); + + // Calcula la lógica de los objetos + if (SDL_GetTicks() - mTicks > mTicksSpeed) + { + // Actualiza el contador de ticks + mTicks = SDL_GetTicks(); + + switch (mSection.subsection) + { + // Sección 1 - Titulo desplazandose + case TITLE_SECTION_1: + { // Actualiza los objetos + mCoffeeBitmap->update(); + mCrisisBitmap->update(); + + // Si los objetos han llegado a su destino, cambiamos de Sección + if (mCoffeeBitmap->hasFinished() && mCrisisBitmap->hasFinished()) + { + mSection.subsection = TITLE_SECTION_2; + + // Pantallazo blanco + SDL_SetRenderDrawColor(mRenderer, 0xFF, 0xFF, 0xFF, 0xFF); + SDL_RenderClear(mRenderer); + SDL_RenderPresent(mRenderer); + } + } + break; + + // Sección 2 - Titulo vibrando + case TITLE_SECTION_2: + { + } + break; + + // Sección 3 - La pantalla de titulo con el menú y la música + case TITLE_SECTION_3: + { + if (mCounter > 0) + { + // Reproduce la música + JA_PlayMusic(mMusic); + + // Calcula la lógica de los objetos + if (SDL_GetTicks() - mTicks > mTicksSpeed) + { + // Actualiza el contador de ticks + mTicks = SDL_GetTicks(); + + mDustBitmapR->update(); + mDustBitmapL->update(); + + // Actualiza la lógica del titulo + mMenu.active->update(); + mFade->update(); + + if (mFade->hasEnded()) + { + switch (mPostFade) + { + case 0: // 1 PLAYER + mSection.name = PROG_SECTION_GAME; + mSection.subsection = GAME_SECTION_PLAY_1P; + JA_StopMusic(); + break; + + case 1: // 2 PLAYERS + mSection.name = PROG_SECTION_GAME; + mSection.subsection = GAME_SECTION_PLAY_2P; + JA_StopMusic(); + break; + + case 2: // QUIT + mSection.name = PROG_SECTION_QUIT; + JA_StopMusic(); + break; + + case 3: // TIME OUT + mCounter = TITLE_COUNTER; + mMenu.active->reset(); + if (mDemo) + { + runDemoGame(); + runInstructions(INSTRUCTIONS_MODE_AUTO); + } + else + mSection.name = PROG_SECTION_LOGO; + break; + + default: + break; + } + } + + // Actualiza el tileado de fondo + updateBG(); + + // Comprueba las entradas para el menu + if (mMenuVisible == true) + { + mMenu.active->checkInput(); + } + + // Comprueba si se ha seleccionado algún item del menú + if (mMenu.active->getName() == "TITLE") + { + switch (mMenu.active->getItemSelected()) + { + case 0: // 1 PLAYER + mPostFade = 0; + mFade->activateFade(); + break; + case 1: // 2 PLAYERS + mPostFade = 1; + mFade->activateFade(); + break; + case 2: // OPTIONS + mMenu.active = mMenu.options; + mOptionsPrevious = *mOptions; + break; + case 3: // QUIT + mPostFade = 2; + mFade->activateFade(); + break; + + default: + break; + } + } + + // Comprueba si se ha seleccionado algún item de opciones + if (mMenu.active->getName() == "OPTIONS") + { + switch (mMenu.active->getItemSelected()) + { + case 0: // Difficulty + if (mOptions->difficulty == DIFFICULTY_EASY) + mOptions->difficulty = DIFFICULTY_NORMAL; + else if (mOptions->difficulty == DIFFICULTY_NORMAL) + mOptions->difficulty = DIFFICULTY_HARD; + else + mOptions->difficulty = DIFFICULTY_EASY; + updateMenuLabels(); + break; + case 1: // PLAYER 1 CONTROLS + updatePlayerInputs(0); + updateMenuLabels(); + break; + case 3: // PLAYER 2 CONTROLS + updatePlayerInputs(1); + updateMenuLabels(); + break; + case 5: // Language + mOptions->language++; + if (mOptions->language == 3) + mOptions->language = 0; + updateMenuLabels(); + break; + case 6: // Display mode + switchFullScreenModeVar(); + if (mOptions->fullScreenMode != 0) + { + mMenu.options->setSelectable(8, false); + mMenu.options->setGreyed(8, true); + } + else + { + mMenu.options->setSelectable(8, true); + mMenu.options->setGreyed(8, false); + } + updateMenuLabels(); + break; + case 8: // Windows size + mOptions->windowSize++; + if (mOptions->windowSize == 5) + mOptions->windowSize = 1; + updateMenuLabels(); + break; + case 9: // FILTER + if (mOptions->filter == FILTER_LINEAL) + mOptions->filter = FILTER_NEAREST; + else + mOptions->filter = FILTER_LINEAL; + updateMenuLabels(); + break; + case 10: // VSYNC + if (mOptions->vSync) + mOptions->vSync = false; + else + mOptions->vSync = true; + updateMenuLabels(); + break; + case 11: // HOW TO PLAY + runInstructions(INSTRUCTIONS_MODE_MANUAL); + break; + case 12: // ACCEPT + applyOptions(); + mMenu.active->reset(); + mMenu.active = mMenu.title; + break; + case 13: // CANCEL + mOptions = &mOptionsPrevious; + updateMenuLabels(); + mMenu.active->reset(); + mMenu.active = mMenu.title; + break; + + default: + break; + } + } + + if (mMenu.active->getName() == "TITLE") + mCounter--; + } + } + else if (mCounter == 0) + { + // if (mDemo) + //{ + // runDemoGame(); + // runInstructions(INSTRUCTIONS_MODE_AUTO); + // } + // else + mSection.name = PROG_SECTION_LOGO; + } + } + break; + + default: + break; + } + } +} + +// Dibuja el objeto en pantalla +void Title::render() +{ + switch (mSection.subsection) + { + // Sección 1 - Titulo desplazandose + case TITLE_SECTION_1: + { + mScreen->start(); // Prepara para empezar a dibujar en la textura de juego + mScreen->clean(bgColor); // Limpia la pantalla + SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, nullptr); // Dibuja el tileado de fondo + mGradient->render(); // Dibuja el degradado + mCoffeeBitmap->render(); // Dibuja los objetos + mCrisisBitmap->render(); // Dibuja los objetos + mScreen->blit(); // Vuelca el contenido del renderizador en pantalla + } + break; + + // Sección 2 - Titulo vibrando + case TITLE_SECTION_2: + { // Reproduce el efecto sonoro + JA_PlaySound(mSound); + + // Agita la pantalla + const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0}; + const int a = mCoffeeBitmap->getPosX(); + const int b = mCrisisBitmap->getPosX(); + for (int n = 0; n < 11 * 3; ++n) + { + // Prepara para empezar a dibujar en la textura de juego + mScreen->start(); + + // Limpia la pantalla + mScreen->clean(bgColor); + + // Dibuja el tileado de fondo + SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, nullptr); + + // Dibuja el degradado + mGradient->render(); + + // Dibuja los objetos + mCoffeeBitmap->setPosX(a + v[n / 3]); + mCrisisBitmap->setPosX(b + v[n / 3]); + mCoffeeBitmap->render(); + mCrisisBitmap->render(); + mDustBitmapR->animate(); + mDustBitmapL->animate(); + mDustBitmapR->render(); + mDustBitmapL->render(); + + // Vuelca el contenido del renderizador en pantalla + mScreen->blit(); + } + + mSection.subsection = TITLE_SECTION_3; + } + + break; + + // Sección 3 - La pantalla de titulo con el menú y la música + case TITLE_SECTION_3: + { // Prepara para empezar a dibujar en la textura de juego + mScreen->start(); + + // Limpia la pantalla + mScreen->clean(bgColor); + + // Dibuja el tileado de fondo + SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, nullptr); + + // Dibuja el degradado + mGradient->render(); + + // Dibuja los objetos + if (mMenu.active->getName() != "OPTIONS") + { + // Bitmaps con el logo/titulo del juego + mCoffeeBitmap->render(); + mCrisisBitmap->render(); + + // Texto con el copyright y versión + mText2->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor); + } + + if (mMenuVisible == true) + { + mMenu.active->render(); + } + + mDustBitmapR->render(); + mDustBitmapL->render(); + + // PRESS ANY KEY! + if ((mCounter % 50 > 14) && (mMenuVisible == false)) + { + mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, mLang->getText(23), 1, noColor, 1, shdwTxtColor); + } + + // Fade + mFade->render(); + + // Vuelca el contenido del renderizador en pantalla + mScreen->blit(); + } + break; + + default: + break; + } +} + +// Comprueba los eventos +void Title::checkEventHandler() +{ + // Comprueba los eventos que hay en la cola + while (SDL_PollEvent(mEventHandler) != 0) + { + // Evento de salida de la aplicación + if (mEventHandler->type == SDL_QUIT) + { + mSection.name = PROG_SECTION_QUIT; + break; + } + + if (mSection.subsection == TITLE_SECTION_3) + { // Si se pulsa alguna tecla durante la tercera sección del titulo + if ((mEventHandler->type == SDL_KEYUP) || (mEventHandler->type == SDL_JOYBUTTONUP)) + { + // Muestra el menu + mMenuVisible = true; + + // Reinicia el contador + mCounter = TITLE_COUNTER; + } + } + } +} + +// Actualiza el tileado de fondo +void Title::updateBG() +{ + if (mBackgroundMode == 0) + { // El tileado de fondo se desplaza en diagonal + ++mBackgroundWindow.x %= 64; + ++mBackgroundWindow.y %= 64; + } + else + { // El tileado de fondo se desplaza en circulo + ++mBackgroundCounter %= 360; + mBackgroundWindow.x = 128 + (int(mSin[(mBackgroundCounter + 270) % 360] * 128)); + mBackgroundWindow.y = 96 + (int(mSin[(360 - mBackgroundCounter) % 360] * 96)); + } +} + // Cambia el valor de la variable de modo de pantalla completa void Title::switchFullScreenModeVar() { @@ -454,387 +823,15 @@ section_t Title::run() { while (mSection.name == PROG_SECTION_TITLE) { - // Sección 1 - Titulo desplazandose - if (mSection.subsection == TITLE_SECTION_1) - { - // Comprueba los eventos que hay en la cola - while (SDL_PollEvent(mEventHandler) != 0) - { - // Evento de salida de la aplicación - if (mEventHandler->type == SDL_QUIT) - { - mSection.name = PROG_SECTION_QUIT; - break; - } - } - - // Calcula la lógica de los objetos - if (SDL_GetTicks() - mTicks > mTicksSpeed) - { - // Actualiza el contador de ticks - mTicks = SDL_GetTicks(); - - // Actualiza los objetos - mCoffeeBitmap->update(); - mCrisisBitmap->update(); - } - - // Prepara para empezar a dibujar en la textura de juego - mScreen->start(); - - // Limpia la pantalla - mScreen->clean(bgColor); - - // Dibuja el tileado de fondo - SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, nullptr); - - // Dibuja el degradado - mGradient->render(); - - // Dibuja los objetos - mCoffeeBitmap->render(); - mCrisisBitmap->render(); - - // Vuelca el contenido del renderizador en pantalla - mScreen->blit(); - - const int EVENT_COMPLETED = 0; // ******************** TEMPORAL PARA COMPILAR - // Si los objetos han llegado a su destino, cambiamos de Sección - if ((mEvents[0] == EVENT_COMPLETED) && (mEvents[0] == EVENT_COMPLETED)) - { - mSection.subsection = TITLE_SECTION_2; - - // Pantallazo blanco - SDL_SetRenderDrawColor(mRenderer, 0xFF, 0xFF, 0xFF, 0xFF); - SDL_RenderClear(mRenderer); - SDL_RenderPresent(mRenderer); - } - } - - // Sección 2 - Titulo vibrando - if (mSection.subsection == TITLE_SECTION_2) - { - // Comprueba los eventos que hay en la cola - while (SDL_PollEvent(mEventHandler) != 0) - { - // Evento de salida de la aplicación - if (mEventHandler->type == SDL_QUIT) - { - mSection.name = PROG_SECTION_QUIT; - break; - } - } - - // Reproduce el efecto sonoro - JA_PlaySound(mSound); - - // Agita la pantalla - int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0}; - int a = mCoffeeBitmap->getPosX(); - int b = mCrisisBitmap->getPosX(); - for (int n = 0; n < 11 * 3; n++) - { - // Prepara para empezar a dibujar en la textura de juego - mScreen->start(); - - // Limpia la pantalla - mScreen->clean(bgColor); - - // Dibuja el tileado de fondo - SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, nullptr); - - // Dibuja el degradado - mGradient->render(); - - // Dibuja los objetos - mCoffeeBitmap->setPosX(a + v[n / 3]); - mCrisisBitmap->setPosX(b + v[n / 3]); - mCoffeeBitmap->render(); - mCrisisBitmap->render(); - mDustBitmapR->animate(); - mDustBitmapL->animate(); - mDustBitmapR->render(); - mDustBitmapL->render(); - - // Vuelca el contenido del renderizador en pantalla - mScreen->blit(); - } - - mSection.subsection = TITLE_SECTION_3; - } - + update(); + render(); // Sección 3 - La pantalla de titulo con el menú y la música - if (mSection.subsection == TITLE_SECTION_3) - { - if (mCounter > 0) - { - // Comprueba los eventos que hay en la cola - while (SDL_PollEvent(mEventHandler) != 0) - { - // Evento de salida de la aplicación - if (mEventHandler->type == SDL_QUIT) - { - mSection.name = PROG_SECTION_QUIT; - break; - } - - if ((mEventHandler->type == SDL_KEYUP) || (mEventHandler->type == SDL_JOYBUTTONUP)) - { - mMenuVisible = true; - mCounter = TITLE_COUNTER; - } - } - - // Si la música no está sonando - if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) - JA_PlayMusic(mMusic); // Reproduce la música - - // Calcula la lógica de los objetos - if (SDL_GetTicks() - mTicks > mTicksSpeed) - { - // Actualiza el contador de ticks - mTicks = SDL_GetTicks(); - - // Actualiza la lógica del titulo - mMenu.active->update(); - mFade->update(); - if (mFade->hasEnded()) - { - switch (mPostFade) - { - case 0: // 1 PLAYER - mSection.name = PROG_SECTION_GAME; - mSection.subsection = GAME_SECTION_PLAY_1P; - JA_StopMusic(); - break; - - case 1: // 2 PLAYERS - mSection.name = PROG_SECTION_GAME; - mSection.subsection = GAME_SECTION_PLAY_2P; - JA_StopMusic(); - break; - - case 2: // QUIT - mSection.name = PROG_SECTION_QUIT; - JA_StopMusic(); - break; - - case 3: // TIME OUT - mCounter = TITLE_COUNTER; - mMenu.active->reset(); - if (mDemo) - { - runDemoGame(); - runInstructions(INSTRUCTIONS_MODE_AUTO); - } - else - mSection.name = PROG_SECTION_LOGO; - break; - - default: - break; - } - } - - // Actualiza el tileado de fondo - switch (mBackgroundMode) - { - case 0: // El tileado de fondo se desplaza en diagonal - mBackgroundWindow.x++; - mBackgroundWindow.x %= 64; - mBackgroundWindow.y++; - mBackgroundWindow.y %= 64; - break; - - case 1: // El tileado de fondo se desplaza en circulo - ++mBackgroundCounter %= 360; - mBackgroundWindow.x = 128 + (int(mSin[(mBackgroundCounter + 270) % 360] * 128)); - mBackgroundWindow.y = 96 + (int(mSin[(360 - mBackgroundCounter) % 360] * 96)); - break; - - default: - break; - } - - // Comprueba las entradas para el menu - if (mMenuVisible == true) - mMenu.active->checkInput(); - - // Comprueba si se ha seleccionado algún item del menú - if (mMenu.active->getName() == "TITLE") - { - switch (mMenu.active->getItemSelected()) - { - case 0: // 1 PLAYER - mPostFade = 0; - mFade->activateFade(); - break; - case 1: // 2 PLAYERS - mPostFade = 1; - mFade->activateFade(); - break; - case 2: // OPTIONS - mMenu.active = mMenu.options; - mOptionsPrevious = *mOptions; - break; - case 3: // QUIT - mPostFade = 2; - mFade->activateFade(); - break; - - default: - break; - } - } - - // Comprueba si se ha seleccionado algún item de opciones - if (mMenu.active->getName() == "OPTIONS") - { - switch (mMenu.active->getItemSelected()) - { - case 0: // Difficulty - if (mOptions->difficulty == DIFFICULTY_EASY) - mOptions->difficulty = DIFFICULTY_NORMAL; - else if (mOptions->difficulty == DIFFICULTY_NORMAL) - mOptions->difficulty = DIFFICULTY_HARD; - else - mOptions->difficulty = DIFFICULTY_EASY; - updateMenuLabels(); - break; - case 1: // PLAYER 1 CONTROLS - updatePlayerInputs(0); - updateMenuLabels(); - break; - case 3: // PLAYER 2 CONTROLS - updatePlayerInputs(1); - updateMenuLabels(); - break; - case 5: // Language - mOptions->language++; - if (mOptions->language == 3) - mOptions->language = 0; - updateMenuLabels(); - break; - case 6: // Display mode - switchFullScreenModeVar(); - if (mOptions->fullScreenMode != 0) - { - mMenu.options->setSelectable(8, false); - mMenu.options->setGreyed(8, true); - } - else - { - mMenu.options->setSelectable(8, true); - mMenu.options->setGreyed(8, false); - } - updateMenuLabels(); - break; - case 8: // Windows size - mOptions->windowSize++; - if (mOptions->windowSize == 5) - mOptions->windowSize = 1; - updateMenuLabels(); - break; - case 9: // FILTER - if (mOptions->filter == FILTER_LINEAL) - mOptions->filter = FILTER_NEAREST; - else - mOptions->filter = FILTER_LINEAL; - updateMenuLabels(); - break; - case 10: // VSYNC - if (mOptions->vSync) - mOptions->vSync = false; - else - mOptions->vSync = true; - updateMenuLabels(); - break; - case 11: // HOW TO PLAY - runInstructions(INSTRUCTIONS_MODE_MANUAL); - break; - case 12: // ACCEPT - applyOptions(); - mMenu.active->reset(); - mMenu.active = mMenu.title; - break; - case 13: // CANCEL - mOptions = &mOptionsPrevious; - updateMenuLabels(); - mMenu.active->reset(); - mMenu.active = mMenu.title; - break; - - default: - break; - } - } - - if (mMenu.active->getName() == "TITLE") - mCounter--; - } - - // Prepara para empezar a dibujar en la textura de juego - mScreen->start(); - - // Limpia la pantalla - mScreen->clean(bgColor); - - // Dibuja el tileado de fondo - SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, nullptr); - - // Dibuja el degradado - mGradient->render(); - - // Dibuja los objetos - if (mMenu.active->getName() != "OPTIONS") - { - // Bitmaps con el logo/titulo del juego - mCoffeeBitmap->render(); - mCrisisBitmap->render(); - - // Texto con el copyright y versión - mText2->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor); - } - - if (mMenuVisible == true) - { - mMenu.active->render(); - } - - mDustBitmapR->animate(); - mDustBitmapL->animate(); - mDustBitmapR->render(); - mDustBitmapL->render(); - - // PRESS ANY KEY! - if ((mCounter % 50 > 14) && (mMenuVisible == false)) - { - mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, mLang->getText(23), 1, noColor, 1, shdwTxtColor); - } - - // Fade - mFade->render(); - - // Vuelca el contenido del renderizador en pantalla - mScreen->blit(); - } - else if (mCounter == 0) - { - if (mDemo) - { - runDemoGame(); - runInstructions(INSTRUCTIONS_MODE_AUTO); - } - else - mSection.name = PROG_SECTION_LOGO; - } - } // Sección Instrucciones - if (mSection.subsection == TITLE_SECTION_INSTRUCTIONS) - { - runInstructions(INSTRUCTIONS_MODE_AUTO); - } + // if (mSection.subsection == TITLE_SECTION_INSTRUCTIONS) + //{ + // runInstructions(INSTRUCTIONS_MODE_AUTO); + //} } return mSection; @@ -884,9 +881,13 @@ bool Title::updatePlayerInputs(int numPlayer) // Incrementa el indice if (mDeviceIndex[numPlayer] < numDevices - 1) + { mDeviceIndex[numPlayer]++; + } else + { mDeviceIndex[numPlayer] = 0; + } printf("deviceindex:%i\n", mDeviceIndex[numPlayer]); // Si coincide con el del otro jugador, se lo intercambian @@ -895,7 +896,9 @@ bool Title::updatePlayerInputs(int numPlayer) const int theOtherPlayer = (numPlayer + 1) % 2; mDeviceIndex[theOtherPlayer]--; if (mDeviceIndex[theOtherPlayer] < 0) + { mDeviceIndex[theOtherPlayer] = numDevices - 1; + } } // Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador @@ -909,20 +912,41 @@ bool Title::updatePlayerInputs(int numPlayer) // Crea el mosaico de fondo del titulo void Title::createTiledBackground() { + // Crea la textura para el mosaico de fondo + mBackground = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH * 2, GAME_HEIGHT * 2); + if (mBackground == nullptr) + { + printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError()); + } + + // Crea los objetos para pintar en la textura de fondo + LTexture *bgTileTexture = new LTexture(mRenderer, mAsset->get("title_bg_tile.png")); + Sprite *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, mRenderer); + + // Prepara para dibujar sobre la textura SDL_SetRenderTarget(mRenderer, mBackground); SDL_SetRenderDrawColor(mRenderer, 0x43, 0x43, 0x4F, 0xFF); SDL_RenderClear(mRenderer); - mTile->setSpriteClip(192, 0, 64, 64); - for (int i = 0; i < 8; i++) - for (int j = 0; j < 6; j++) + // Rellena la textura con el tile + tile->setSpriteClip(192, 0, 64, 64); + for (int i = 0; i < 8; ++i) + { + for (int j = 0; j < 6; ++j) { - mTile->setPosX(i * 64); - mTile->setPosY(j * 64); - mTile->render(); + tile->setPosX(i * 64); + tile->setPosY(j * 64); + tile->render(); } + } + // Vuelve a colocar el renderizador apuntando a la pantalla SDL_SetRenderTarget(mRenderer, nullptr); + + // Libera la memoria utilizada por los objetos + bgTileTexture->unload(); + delete bgTileTexture; + delete tile; } // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones diff --git a/source/title.h b/source/title.h index 5dfc6bb..17c660f 100644 --- a/source/title.h +++ b/source/title.h @@ -42,36 +42,42 @@ private: }; // Objetos - SDL_Renderer *mRenderer; // El renderizador de la ventana - Screen *mScreen; // Objeto encargado de dibujar en pantalla - Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos - Input *mInput; // Objeto para leer las entradas de teclado o mando - Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas - SDL_Event *mEventHandler; // Manejador de eventos + SDL_Renderer *mRenderer; // El renderizador de la ventana + Screen *mScreen; // Objeto encargado de dibujar en pantalla + Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos + Input *mInput; // Objeto para leer las entradas de teclado o mando + Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas + Instructions *mInstructions; // Objeto para la sección de las instrucciones + Game *mDemoGame; // Objeto para lanzar la demo del juego + SDL_Event *mEventHandler; // Manejador de eventos + + LTexture *dustTexture; // Textura con los graficos del polvo + LTexture *coffeeTexture; // Textura con los graficos de la palabra coffee + LTexture *crisisTexture; // Textura con los graficos de la plabra crisis + LTexture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo + + SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo + SDL_Texture *mBackground; // Textura dibujar el fondo del titulo + AnimatedSprite *mDustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo AnimatedSprite *mDustBitmapR; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo - LTexture *mItemsTexture; // Textura con los gráficos de los items para las instrucciones - LTexture *mTitleTexture; // Textura con los graficos para el titulo - SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo - SDL_Texture *mBackground; // Textura dibujar el fondo del titulo - SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo - SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo - Sprite *mTile; // Sprite para dibujar el fondo de pantalla del título - Sprite *mGradient; // Sprite para dibujar el degradado del titulo - Text *mText; // Objeto de texto para poder escribir textos en pantalla - Text *mText2; // Objeto de texto para poder escribir textos en pantalla - Fade *mFade; // Objeto para realizar fundidos en pantalla - Instructions *mInstructions; // Objeto para la sección de las instrucciones - Game *mDemoGame; // Objeto para lanzar la demo del juego + + SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo + SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo + + Sprite *mGradient; // Sprite para dibujar el degradado del titulo + + Text *mText; // Objeto de texto para poder escribir textos en pantalla + Text *mText2; // Objeto de texto para poder escribir textos en pantalla + Fade *mFade; // Objeto para realizar fundidos en pantalla // Variable JA_Music mMusic; // Musica para el titulo JA_Sound mSound; // Sonido con el impacto del título - int mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo - int mCounter; // Temporizador para la pantalla de titulo + int mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo + int mCounter; // Temporizador para la pantalla de titulo Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa Uint8 mBackgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo - Uint8 mEvents[TITLE_TOTAL_EVENTS]; // Vector para coordinar los eventos de la pantalla de titulo float mSin[360]; // Vector con los valores del seno precalculados bool mMenuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente bool mDemo; // Indica si el modo demo estará activo @@ -85,6 +91,18 @@ private: std::vector mAvailableInputDevices; // Vector con todos los metodos de control disponibles int mDeviceIndex[2]; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles + // Actualiza las variables del objeto + void update(); + + // Dibuja el objeto en pantalla + void render(); + + // Comprueba los eventos + void checkEventHandler(); + + //Actualiza el tileado de fondo + void updateBG(); + // Cambia el valor de la variable de modo de pantalla completa void switchFullScreenModeVar();