Ver Fonte

Merge pull request #27 from CrystalPointA4/musicInclude

Music include
Kenneth van Ewijk há 9 anos atrás
pai
commit
3cf6bf5857
13 ficheiros alterados com 34 adições e 25 exclusões
  1. 7 2
      Crystal.cpp
  2. 3 0
      Crystal.h
  3. 4 2
      CrystalPoint.vcxproj
  4. 8 2
      CrystalPoint.vcxproj.filters
  5. 2 10
      Enemy.cpp
  6. BIN
      WAVE/Crystal.wav
  7. BIN
      WAVE/enemy.wav
  8. BIN
      WAVE/ghostEnemy.wav
  9. BIN
      WAVE/test1.wav
  10. BIN
      WAVE/world1.wav
  11. 1 0
      World.cpp
  12. 5 5
      worlds/rock.json
  13. 4 4
      worlds/small.json

+ 7 - 2
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;

+ 3 - 0
Crystal.h

@@ -1,6 +1,7 @@
 #pragma once
 #include "Entity.h"
 #include <string>
+#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;
 };

+ 4 - 2
CrystalPoint.vcxproj

@@ -230,8 +230,10 @@
     <None Include="worlds\worlds.json" />
   </ItemGroup>
   <ItemGroup>
-    <Media Include="WAVE\bond.wav" />
-    <Media Include="WAVE\Sound.wav" />
+    <Media Include="WAVE\Crystal.wav" />
+    <Media Include="WAVE\ghostEnemy.wav" />
+    <Media Include="WAVE\portal.wav" />
+    <Media Include="WAVE\world1.wav" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 8 - 2
CrystalPoint.vcxproj.filters

@@ -243,10 +243,16 @@
     </None>
   </ItemGroup>
   <ItemGroup>
-    <Media Include="WAVE\Sound.wav">
+    <Media Include="WAVE\Crystal.wav">
       <Filter>Resource Files</Filter>
     </Media>
-    <Media Include="WAVE\bond.wav">
+    <Media Include="WAVE\portal.wav">
+      <Filter>Resource Files</Filter>
+    </Media>
+    <Media Include="WAVE\ghostEnemy.wav">
+      <Filter>Resource Files</Filter>
+    </Media>
+    <Media Include="WAVE\world1.wav">
       <Filter>Resource Files</Filter>
     </Media>
   </ItemGroup>

+ 2 - 10
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;		
 	}
-
 }

BIN
WAVE/Crystal.wav


BIN
WAVE/enemy.wav


BIN
WAVE/ghostEnemy.wav


BIN
WAVE/test1.wav


BIN
WAVE/test2.wav → WAVE/world1.wav


+ 1 - 0
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);		

+ 5 - 5
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",

+ 4 - 4
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 ],