diff --git a/media/sound/death.wav b/media/sound/death.wav index 00d3b4c..ec04951 100644 Binary files a/media/sound/death.wav and b/media/sound/death.wav differ diff --git a/media/title/_loading_screen2.png b/media/title/_loading_screen2.png new file mode 100644 index 0000000..9fd617d Binary files /dev/null and b/media/title/_loading_screen2.png differ diff --git a/media/title/loading_screen2.png b/media/title/loading_screen2.png index 9fd617d..023c8ff 100644 Binary files a/media/title/loading_screen2.png and b/media/title/loading_screen2.png differ diff --git a/source/director.cpp b/source/director.cpp index 6d41599..a578dd8 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -197,6 +197,31 @@ bool Director::setFileList() asset->add("/media/music/loading_sound3.ogg", music); asset->add("/media/sound/item.wav", sound); + asset->add("/media/sound/death.wav", sound); + asset->add("/media/sound/jump1.wav", sound); + asset->add("/media/sound/jump2.wav", sound); + asset->add("/media/sound/jump3.wav", sound); + asset->add("/media/sound/jump4.wav", sound); + asset->add("/media/sound/jump5.wav", sound); + asset->add("/media/sound/jump6.wav", sound); + asset->add("/media/sound/jump7.wav", sound); + asset->add("/media/sound/jump8.wav", sound); + asset->add("/media/sound/jump9.wav", sound); + asset->add("/media/sound/jump10.wav", sound); + asset->add("/media/sound/jump11.wav", sound); + asset->add("/media/sound/jump12.wav", sound); + asset->add("/media/sound/jump13.wav", sound); + asset->add("/media/sound/jump14.wav", sound); + asset->add("/media/sound/jump15.wav", sound); + asset->add("/media/sound/jump16.wav", sound); + asset->add("/media/sound/jump17.wav", sound); + asset->add("/media/sound/jump18.wav", sound); + asset->add("/media/sound/jump19.wav", sound); + asset->add("/media/sound/jump20.wav", sound); + asset->add("/media/sound/jump21.wav", sound); + asset->add("/media/sound/jump22.wav", sound); + asset->add("/media/sound/jump23.wav", sound); + asset->add("/media/sound/jump24.wav", sound); asset->add("/media/logo/jailgames.png", bitmap); asset->add("/media/logo/since_1998.png", bitmap); diff --git a/source/game.cpp b/source/game.cpp index cf137c8..2c5b58e 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -17,7 +17,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D this->screen = screen; this->input = input; this->debug = debug; - debug->setEnabled(true); + this->debug->setEnabled(true); // Crea los objetos scoreboard = new ScoreBoard(renderer, asset, &playerLives, &itemsPicked, &clock); @@ -27,6 +27,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D eventHandler = new SDL_Event(); text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); music = JA_LoadMusic(asset->get("game.ogg").c_str()); + deathSound = JA_LoadSound(asset->get("death.wav").c_str()); test = new Test(renderer, screen, asset, debug); // Inicializa el resto de variables @@ -57,6 +58,9 @@ Game::~Game() delete eventHandler; delete text; + JA_DeleteMusic(music); + JA_DeleteSound(deathSound); + delete test; } @@ -316,6 +320,9 @@ void Game::killPlayer() delete room; delete player; + // Sonido + JA_PlaySound(deathSound); + // Crea la nueva habitación y el nuevo jugador room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &itemsPicked, debug); player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, input, room, debug); diff --git a/source/game.h b/source/game.h index 20ac63c..37f9032 100644 --- a/source/game.h +++ b/source/game.h @@ -44,6 +44,7 @@ private: int playerLives; // Lleva la cuenta de ls vidas restantes del jugador int itemsPicked; // Lleva la cuenta de los objetos recogidos Uint32 clock; // Cuenta el tiempo que dura la partida + JA_Sound deathSound; // Sonido a reproducir cuando muere el jugador Test *test; // Actualiza el juego, las variables, comprueba la entrada, etc. diff --git a/source/item.cpp b/source/item.cpp index a956f21..9f9b72b 100644 --- a/source/item.cpp +++ b/source/item.cpp @@ -61,12 +61,6 @@ void Item::update() counter++; } -// Coge el objeto -void Item::pick() -{ - sprite->setEnabled(false); -} - // Obtiene el rectangulo de colision del objeto SDL_Rect &Item::getCollider() { diff --git a/source/item.h b/source/item.h index 6bff79f..d6211af 100644 --- a/source/item.h +++ b/source/item.h @@ -51,9 +51,6 @@ public: // Actualiza las variables del objeto void update(); - // Coge el item - void pick(); - // Obtiene el rectangulo de colision del objeto SDL_Rect &getCollider(); diff --git a/source/player.cpp b/source/player.cpp index c25c83e..c5c2de0 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -49,6 +49,30 @@ Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Ren colliderPoints.insert(colliderPoints.end(), {p, p, p, p, p, p, p, p}); underFeet.insert(underFeet.end(), {p, p}); feet.insert(feet.end(), {p, p}); + jumpSound.push_back(JA_LoadSound(asset->get("jump1.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump2.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump3.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump4.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump5.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump6.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump7.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump8.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump9.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump10.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump11.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump12.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump13.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump14.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump15.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump16.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump17.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump18.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump19.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump20.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump21.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump22.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump23.wav").c_str())); + jumpSound.push_back(JA_LoadSound(asset->get("jump24.wav").c_str())); r = {0, 0, 0, 0}; } @@ -58,6 +82,11 @@ Player::~Player() { delete texture; delete sprite; + + for (auto s : jumpSound) + { + JA_DeleteSound(s); + } } // Pinta el jugador en pantalla @@ -80,7 +109,7 @@ void Player::render() // Pinta el rectangulo de movimiento SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); SDL_RenderFillRect(renderer, &r); - debug->add("RECT: " + std::to_string(r.x) +","+ std::to_string(r.y) +","+ std::to_string(r.w) +","+ std::to_string(r.h)); + debug->add("RECT: " + std::to_string(r.x) + "," + std::to_string(r.y) + "," + std::to_string(r.w) + "," + std::to_string(r.h)); } } @@ -125,6 +154,7 @@ void Player::checkInput() setState(s_jumping); vy = -maxVY; jump_ini = y; + JA_PlaySound(jumpSound[0]); } } diff --git a/source/player.h b/source/player.h index e794f58..b27ae8b 100644 --- a/source/player.h +++ b/source/player.h @@ -62,6 +62,7 @@ public: SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento int jump_ini; // Valor del eje Y en el que se inicia el salto float maxVY; // Velocidad máxima que puede alcanzar al desplazarse en vertical + std::vector jumpSound; // Vecor con todos los sonidos del salto SDL_Rect r; // Comprueba las entradas y modifica variables diff --git a/source/utils.cpp b/source/utils.cpp index 0d3da07..aace260 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,4 +1,5 @@ #include "utils.h" +#include // Calcula el cuadrado de la distancia entre dos puntos double distanceSquared(int x1, int y1, int x2, int y2)