diff --git a/Crystal.cpp b/Crystal.cpp index 6ced677..c1f4957 100644 --- a/Crystal.cpp +++ b/Crystal.cpp @@ -7,18 +7,22 @@ Crystal::Crystal(const std::string & filled, const std::string & empty, const Ve { this->filled = Model::load(filled); this->empty = Model::load(empty); - model = this->filled; - + model = this->filled; this->position = position; this->rotation = rotation; this->scale = scale; this->canCollide = true; isFilled = true; + + sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/Crystal.wav", false); + music = CrystalPoint::GetSoundSystem().GetSound(sound_id); + music->SetPos(position, Vec3f()); } Crystal::~Crystal() { + CrystalPoint::GetSoundSystem().UnloadSound(sound_id); if (model) Model::unload(model); @@ -41,6 +45,7 @@ void Crystal::collide() { if (isFilled) { + music->Play(); Player::getInstance()->crystals++; isFilled = false; model = empty; diff --git a/Crystal.h b/Crystal.h index 1f9a54f..5dbc03e 100644 --- a/Crystal.h +++ b/Crystal.h @@ -1,6 +1,7 @@ #pragma once #include "Entity.h" #include +#include "CrystalPoint.h" class Crystal : public Entity @@ -14,6 +15,8 @@ public: void draw(); void collide(); private: + int sound_id; + Sound* music; Model* filled; Model* empty; }; diff --git a/CrystalPoint.vcxproj b/CrystalPoint.vcxproj index 6435a83..7868161 100644 --- a/CrystalPoint.vcxproj +++ b/CrystalPoint.vcxproj @@ -230,8 +230,10 @@ - - + + + + diff --git a/CrystalPoint.vcxproj.filters b/CrystalPoint.vcxproj.filters index 84737cb..cc3baac 100644 --- a/CrystalPoint.vcxproj.filters +++ b/CrystalPoint.vcxproj.filters @@ -243,10 +243,16 @@ - + Resource Files - + + Resource Files + + + Resource Files + + Resource Files diff --git a/Enemy.cpp b/Enemy.cpp index b16231a..d46e4fb 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -34,11 +34,10 @@ Enemy::Enemy(const std::string &fileName, Enemy::~Enemy() { - + music->Stop(); + CrystalPoint::GetSoundSystem().UnloadSound(hit_sound_id); if (model) Model::unload(model); - - CrystalPoint::GetSoundSystem().UnloadSound(hit_sound_id); } void Enemy::draw() @@ -114,14 +113,7 @@ void Enemy::update(float delta) else { attack = true; - if (music->IsPlaying() == true) - { -// music->Pause(); - music->Stop(); - } } - rotation.y = atan2f(dx, dz) * 180 / M_PI; } - } \ No newline at end of file diff --git a/WAVE/Crystal.wav b/WAVE/Crystal.wav new file mode 100644 index 0000000..2d13707 Binary files /dev/null and b/WAVE/Crystal.wav differ diff --git a/WAVE/enemy.wav b/WAVE/enemy.wav deleted file mode 100644 index 89e9dae..0000000 Binary files a/WAVE/enemy.wav and /dev/null differ diff --git a/WAVE/ghostEnemy.wav b/WAVE/ghostEnemy.wav new file mode 100644 index 0000000..d69f976 Binary files /dev/null and b/WAVE/ghostEnemy.wav differ diff --git a/WAVE/test1.wav b/WAVE/test1.wav deleted file mode 100644 index e8e4fb8..0000000 Binary files a/WAVE/test1.wav and /dev/null differ diff --git a/WAVE/test2.wav b/WAVE/world1.wav similarity index 60% rename from WAVE/test2.wav rename to WAVE/world1.wav index 364ff42..0d99798 100644 Binary files a/WAVE/test2.wav and b/WAVE/world1.wav differ diff --git a/World.cpp b/World.cpp index 0803c32..63d8b77 100644 --- a/World.cpp +++ b/World.cpp @@ -327,6 +327,7 @@ void World::update(float elapsedTime) if (remove) { + delete enemies[count]; player->XpUp(enemies[count]->xp); enemies.erase(enemies.begin() + count); player->HpUp(10); diff --git a/worlds/rock.json b/worlds/rock.json index ca70643..be7bb51 100644 --- a/worlds/rock.json +++ b/worlds/rock.json @@ -3,7 +3,7 @@ "heightmap": "worlds/rockHeightmap.png", "texture": "worlds/rockStone2.png", "skybox": "skyboxes/water/", - "music": "WAVE/test2.wav", + "music": "WAVE/world1.wav", "object-templates": [ { "color": 50, @@ -92,10 +92,10 @@ }, "enemies": [ { - "file": "models/squid/Blooper.obj", - "pos": [ 20, 5, 10 ], - "scale": 0.01, - "music": "WAVE/enemy.wav" + "file": "models/squid/Blooper.obj", + "pos": [ 30, 10, 10 ], + "scale": 0.01, + "music": "WAVE/ghostEnemy.wav" }], "crystal": { "full texture": "models/crystal/Crystal.obj", diff --git a/worlds/small.json b/worlds/small.json index e703390..c80d509 100644 --- a/worlds/small.json +++ b/worlds/small.json @@ -9,7 +9,7 @@ "collision": true } ], - "music": "WAVE/test1.wav" + "music": "WAVE/world1.wav" }, "player": { "startposition": [ 20, 0, 20 ] @@ -24,7 +24,7 @@ "file": "models/squid/Blooper.obj", "pos": [ 20, 5, 10 ], "scale": 0.01, - "music": "WAVE/enemy.wav", + "music": "WAVE/ghostEnemy.wav" "health": 10, "damage": 2 }, @@ -32,13 +32,13 @@ "file": "models/squid/Blooper.obj", "pos": [ 30, 10, 10 ], "scale": 0.01, - "music": "WAVE/enemy.wav", + "music": "WAVE/ghostEnemy.wav" "health": 15, "damage": 2 }], "crystal": { "full texture": "models/crystal/Crystal.obj", - "empty texture": "models/crystal/PickedUpCrystal.obj", + "empty texture": "models/crystal/PickedUpCrystal.obj", "instances": [ { "pos": [ 31, 5, 33 ],