From 53c0d950565d39f2c00a7f6dfb8ff8529df7b770 Mon Sep 17 00:00:00 2001 From: Francisco Demartino Date: Tue, 4 Nov 2014 13:40:46 -0300 Subject: [PATCH 1/2] misc: assign the best sounds available for creation and dying --- cpp/game_main.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cpp/game_main.cpp b/cpp/game_main.cpp index 8ecb37597b..0d97dccab1 100644 --- a/cpp/game_main.cpp +++ b/cpp/game_main.cpp @@ -168,13 +168,28 @@ GameMain::GameMain(Engine *engine) foundation_size.se ); + int creation_sound = building.sound_creation0; + int dying_sound = building.sound_dying; + + if (creation_sound == -1) { + creation_sound = building.sound_creation1; + } + + if (creation_sound == -1) { + creation_sound = building.sound_selection; + } + + if (dying_sound == -1) { + dying_sound = 323; //generic explosion sound + } + TestBuilding *newbuilding = new TestBuilding{ this->assetmanager.get_texture(tex_fname), building.name, foundation_size, building.terrain_id, - building.sound_creation0, - building.sound_dying, + creation_sound, + dying_sound }; this->available_buildings.push_back(newbuilding); From 4d0cf9d68e0473e13d0035e066891a8ce16056d6 Mon Sep 17 00:00:00 2001 From: Francisco Demartino Date: Thu, 30 Oct 2014 03:42:55 -0300 Subject: [PATCH 2/2] Add a sound_id_destruction to TerrainObject and play it on building destruction --- cpp/game_main.cpp | 8 +++----- cpp/terrain_object.cpp | 12 +++++++----- cpp/terrain_object.h | 4 +++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cpp/game_main.cpp b/cpp/game_main.cpp index 0d97dccab1..9dc8546112 100644 --- a/cpp/game_main.cpp +++ b/cpp/game_main.cpp @@ -401,18 +401,16 @@ bool GameMain::on_input(SDL_Event *e) { if (obj != nullptr) { obj->remove(); this->placed_buildings.erase(obj); + this->available_sounds[obj->sound_id_destruction].play(); delete obj; - - // TODO: play destruction sound - //int rand = util::random_range(0, obj->destruction_snd_count + 1); - //sounds[rand].play() } else { TestBuilding *newbuilding = this->available_buildings[this->editor_current_building]; int coloring = util::random_range(1, 8 + 1); TerrainObject *newobj = new TerrainObject( newbuilding->texture, newbuilding->foundation_size, - coloring + coloring, + newbuilding->sound_id_destruction ); // try to place the obj, it knows best whether it will fit. diff --git a/cpp/terrain_object.cpp b/cpp/terrain_object.cpp index a637a98062..a22a885c0d 100644 --- a/cpp/terrain_object.cpp +++ b/cpp/terrain_object.cpp @@ -17,11 +17,13 @@ namespace openage { TerrainObject::TerrainObject(Texture *tex, coord::tile_delta foundation_size, - unsigned player) { - this->placed = false; - this->texture = tex; - this->size = foundation_size; - this->player = player; + unsigned player, int sound_id_destruction) { + + this->placed = false; + this->texture = tex; + this->size = foundation_size; + this->player = player; + this->sound_id_destruction = sound_id_destruction; this->occupied_chunk_count = 0; } diff --git a/cpp/terrain_object.h b/cpp/terrain_object.h index 8c8e51acc5..993c85d5d6 100644 --- a/cpp/terrain_object.h +++ b/cpp/terrain_object.h @@ -29,13 +29,15 @@ terrain object class represents one immobile object on the map (building, trees, */ class TerrainObject { public: - TerrainObject(Texture *tex, coord::tile_delta foundation_size, unsigned player); + TerrainObject(Texture *tex, coord::tile_delta foundation_size, unsigned player, int sound_id_destruction); ~TerrainObject(); coord::tile start_pos; coord::phys3 draw_pos; coord::tile end_pos; + int sound_id_destruction; + /** * tests whether this terrain object will fit at the given position. *