From 901757b9b228c3a58da544cae58cdf1b8b8f4ef3 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 5 Oct 2022 13:02:57 +0200 Subject: [PATCH] Actualizado .gitignore --- .gitignore | 1 + source/game.cpp | 91 ++++++++++++++++++++++++++----------------------- source/game.h | 2 +- todo.txt | 3 +- 4 files changed, 53 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 1b4172d..b484c47 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.DS_Store bin data/config.txt +data/config.bin data/score.bin \ No newline at end of file diff --git a/source/game.cpp b/source/game.cpp index 51b3921..a4eac53 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -10,7 +10,6 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr this->lang = lang; this->input = input; this->options = options; - onePlayerControl = options->input[0].deviceType; // Pasa variables this->demo.enabled = demo; @@ -18,48 +17,23 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr this->currentStage = 5; // currentStage; lastStageReached = currentStage; if (numPlayers == 1) - { + { // Si solo juega un jugador, permite jugar tanto con teclado como con mando + onePlayerControl = options->input[0].deviceType; options->input[0].deviceType = INPUT_USE_ANY; } difficulty = options->difficulty; // Crea los objetos - balloon1Texture = new LTexture(renderer, asset->get("balloon1.png")); - balloon2Texture = new LTexture(renderer, asset->get("balloon2.png")); - balloon3Texture = new LTexture(renderer, asset->get("balloon3.png")); - balloon4Texture = new LTexture(renderer, asset->get("balloon4.png")); - bulletTexture = new LTexture(renderer, asset->get("bullet.png")); - - gameBuildingsTexture = new LTexture(renderer, asset->get("game_buildings.png")); - gameCloudsTexture = new LTexture(renderer, asset->get("game_clouds.png")); - gameGrassTexture = new LTexture(renderer, asset->get("game_grass.png")); - gamePowerMeterTexture = new LTexture(renderer, asset->get("game_power_meter.png")); - gameSkyColorsTexture = new LTexture(renderer, asset->get("game_sky_colors.png")); - gameTextTexture = new LTexture(renderer, asset->get("game_text.png")); - itemTexture = new LTexture(renderer, asset->get("items.png")); - balloon1Animation = new std::vector; balloon2Animation = new std::vector; balloon3Animation = new std::vector; balloon4Animation = new std::vector; - - loadAnimations(asset->get("balloon1.ani"), balloon1Animation); - loadAnimations(asset->get("balloon2.ani"), balloon2Animation); - loadAnimations(asset->get("balloon3.ani"), balloon3Animation); - loadAnimations(asset->get("balloon4.ani"), balloon4Animation); - - text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); - textScoreBoard = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer); - textBig = new Text(asset->get("smb2_big.png"), asset->get("smb2_big.txt"), renderer); - textNokia2 = new Text(asset->get("nokia2.png"), asset->get("nokia2.txt"), renderer); - textNokiaBig2 = new Text(asset->get("nokia_big2.png"), asset->get("nokia_big2.txt"), renderer); - - gameOverMenu = new Menu(renderer, asset, input, asset->get("gameover.men")); - pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men")); - fade = new Fade(renderer); eventHandler = new SDL_Event(); + // Carga los recursos + loadMedia(); + clouds1A = new MovingSprite(0, 0, 256, 52, -0.4f, 0.0f, 0.0f, 0.0f, gameCloudsTexture, renderer); clouds1B = new MovingSprite(256, 0, 256, 52, -0.4f, 0.0f, 0.0f, 0.0f, gameCloudsTexture, renderer); clouds2A = new MovingSprite(0, 52, 256, 32, -0.2f, 0.0f, 0.0f, 0.0f, gameCloudsTexture, renderer); @@ -75,6 +49,11 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer); powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer); + + // Carga ficheros + loadScoreFile(); + loadDemoFile(); + // Inicializa las variables necesarias para la sección 'Game' init(); } @@ -84,7 +63,11 @@ Game::~Game() saveScoreFile(); saveDemoFile(); - options->input[0].deviceType = onePlayerControl; + // Restaura el metodo de control + if (numPlayers == 1) + { + options->input[0].deviceType = onePlayerControl; + } // Elimina todos los objetos contenidos en vectores deleteAllVectorObjects(); @@ -174,13 +157,6 @@ Game::~Game() // Inicializa las variables necesarias para la sección 'Game' void Game::init() { - // Carga los recursos - loadMedia(); - - // Carga ficheros - loadScoreFile(); - loadDemoFile(); - ticks = 0; ticksSpeed = 15; @@ -357,9 +333,40 @@ void Game::init() } // Carga los recursos necesarios para la sección 'Game' -bool Game::loadMedia() +void Game::loadMedia() { - bool success = true; + std::cout << "** LOADING RESOURCES FOR GAME SECTION" << std::endl; + + // Texturas + balloon1Texture = new LTexture(renderer, asset->get("balloon1.png")); + balloon2Texture = new LTexture(renderer, asset->get("balloon2.png")); + balloon3Texture = new LTexture(renderer, asset->get("balloon3.png")); + balloon4Texture = new LTexture(renderer, asset->get("balloon4.png")); + bulletTexture = new LTexture(renderer, asset->get("bullet.png")); + gameBuildingsTexture = new LTexture(renderer, asset->get("game_buildings.png")); + gameCloudsTexture = new LTexture(renderer, asset->get("game_clouds.png")); + gameGrassTexture = new LTexture(renderer, asset->get("game_grass.png")); + gamePowerMeterTexture = new LTexture(renderer, asset->get("game_power_meter.png")); + gameSkyColorsTexture = new LTexture(renderer, asset->get("game_sky_colors.png")); + gameTextTexture = new LTexture(renderer, asset->get("game_text.png")); + itemTexture = new LTexture(renderer, asset->get("items.png")); + + // Animaciones + loadAnimations(asset->get("balloon1.ani"), balloon1Animation); + loadAnimations(asset->get("balloon2.ani"), balloon2Animation); + loadAnimations(asset->get("balloon3.ani"), balloon3Animation); + loadAnimations(asset->get("balloon4.ani"), balloon4Animation); + + // Texto + text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); + textScoreBoard = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer); + textBig = new Text(asset->get("smb2_big.png"), asset->get("smb2_big.txt"), renderer); + textNokia2 = new Text(asset->get("nokia2.png"), asset->get("nokia2.txt"), renderer); + textNokiaBig2 = new Text(asset->get("nokia_big2.png"), asset->get("nokia_big2.txt"), renderer); + + // Menus + gameOverMenu = new Menu(renderer, asset, input, asset->get("gameover.men")); + pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men")); // Sonidos balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str()); @@ -381,7 +388,7 @@ bool Game::loadMedia() // Musicas gameMusic = JA_LoadMusic(asset->get("playing.ogg").c_str()); - return success; + std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl << std::endl; } // Carga el fichero de puntos diff --git a/source/game.h b/source/game.h index 84b254c..937feda 100644 --- a/source/game.h +++ b/source/game.h @@ -245,7 +245,7 @@ private: void init(); // Carga los recursos necesarios para la sección 'Game' - bool loadMedia(); + void loadMedia(); // Carga el fichero de puntos bool loadScoreFile(); diff --git a/todo.txt b/todo.txt index ee0cc27..9241b26 100644 --- a/todo.txt +++ b/todo.txt @@ -20,4 +20,5 @@ x no pone la animacion corecta al no disparar con el powerup que grite "yiiijaa!" o algo parecido al coger la maquina de cafe o que diga DIMONIS! en un globo de texto que se evapore podrian salir comentarios aleatoriamente o con ciertos eventos (falta ver si no estorbará) -que se vea el nivel de dificultad \ No newline at end of file +que se vea el nivel de dificultad +cargar y guardar la configuración \ No newline at end of file