forked from jaildesigner-jailgames/jaildoctors_dilemma
Añadido el sonido de coger objetos
This commit is contained in:
BIN
media/sound/item.ogg
Normal file
BIN
media/sound/item.ogg
Normal file
Binary file not shown.
BIN
media/sound/item.wav
Normal file
BIN
media/sound/item.wav
Normal file
Binary file not shown.
@@ -185,6 +185,8 @@ bool Director::setFileList()
|
||||
asset->add("/media/items/items.png", bitmap);
|
||||
|
||||
asset->add("/media/music/jd.ogg", music);
|
||||
|
||||
asset->add("/media/sound/item.wav", sound);
|
||||
|
||||
return asset->check();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Asset *asset, ItemTrac
|
||||
texture = new LTexture();
|
||||
load(file_path);
|
||||
loadTextureFromFile(texture, asset->get(tileset), renderer);
|
||||
itemSound = JA_LoadSound(asset->get("item.wav").c_str());
|
||||
|
||||
// Crea la textura para el mapa de tiles de la habitación
|
||||
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
@@ -33,6 +34,8 @@ Room::~Room()
|
||||
delete texture;
|
||||
texture = nullptr;
|
||||
|
||||
JA_DeleteSound(itemSound);
|
||||
|
||||
SDL_DestroyTexture(mapTexture);
|
||||
mapTexture = nullptr;
|
||||
|
||||
@@ -540,15 +543,27 @@ bool Room::enemyCollision(SDL_Rect &rect)
|
||||
bool Room::itemCollision(SDL_Rect &rect)
|
||||
{
|
||||
bool collision = false;
|
||||
for (auto item : items)
|
||||
for (int i =0;i<items.size();i++)
|
||||
{
|
||||
if (checkCollision(rect, item->getCollider()))
|
||||
if (checkCollision(rect, items[i]->getCollider()))
|
||||
{
|
||||
item->pick();
|
||||
itemTracker->addItem(name, item->getPos());
|
||||
itemTracker->addItem(name, items[i]->getPos());
|
||||
delete items[i];
|
||||
items.erase(items.begin()+i);
|
||||
JA_PlaySound(itemSound);
|
||||
collision = true;
|
||||
}
|
||||
}
|
||||
//for (auto item : items)
|
||||
//{
|
||||
// if (checkCollision(rect, item->getCollider()))
|
||||
// {
|
||||
// itemTracker->addItem(name, item->getPos());
|
||||
// item->pick();
|
||||
// JA_PlaySound(itemSound);
|
||||
// collision = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
return collision;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "item.h"
|
||||
#include "item_tracker.h"
|
||||
#include "const.h"
|
||||
#include "jail_audio.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -51,6 +52,7 @@ private:
|
||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación
|
||||
JA_Sound itemSound; // Sonido producido al coger un objeto
|
||||
|
||||
// Carga las variables desde un fichero
|
||||
bool load(std::string file_path);
|
||||
|
||||
Reference in New Issue
Block a user