这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cpp/game_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ GameMain::GameMain(Engine *engine)
foundation_size.ne,
foundation_size.se
);
log::msg(" sound_creation0: %5d, sound_creation1: %5d, sound_dying: %5d",
building.sound_creation0,
building.sound_creation1,
building.sound_dying
);

TestBuilding *newbuilding = new TestBuilding{
this->assetmanager.get_texture(tex_fname),
Expand Down Expand Up @@ -386,18 +391,17 @@ 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.
Expand Down
12 changes: 7 additions & 5 deletions cpp/terrain_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion cpp/terrain_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down