forked from jaildesigner-jailgames/jaildoctors_dilemma
Añadiendo efectos de sonido
This commit is contained in:
Binary file not shown.
BIN
media/title/_loading_screen2.png
Normal file
BIN
media/title/_loading_screen2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 7.1 KiB |
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<JA_Sound> jumpSound; // Vecor con todos los sonidos del salto
|
||||
SDL_Rect r;
|
||||
|
||||
// Comprueba las entradas y modifica variables
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "utils.h"
|
||||
#include <math.h>
|
||||
|
||||
// Calcula el cuadrado de la distancia entre dos puntos
|
||||
double distanceSquared(int x1, int y1, int x2, int y2)
|
||||
|
||||
Reference in New Issue
Block a user