Quellcode durchsuchen

MusicIncluded, crystals

Aaldert vor 9 Jahren
Ursprung
Commit
d56625e19a
8 geänderte Dateien mit 29 neuen und 9 gelöschten Zeilen
  1. 7 2
      Crystal.cpp
  2. 3 0
      Crystal.h
  3. 5 2
      CrystalPoint.vcxproj
  4. 11 2
      CrystalPoint.vcxproj.filters
  5. BIN
      WAVE/Crystal.wav
  6. BIN
      WAVE/enemy.wav
  7. BIN
      WAVE/ghostEnemy.wav
  8. 3 3
      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;
 };

+ 5 - 2
CrystalPoint.vcxproj

@@ -216,8 +216,11 @@
     <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\test1.wav" />
+    <Media Include="WAVE\test2.wav" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 11 - 2
CrystalPoint.vcxproj.filters

@@ -204,10 +204,19 @@
     </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\ghostEnemy.wav">
+      <Filter>Resource Files</Filter>
+    </Media>
+    <Media Include="WAVE\portal.wav">
+      <Filter>Resource Files</Filter>
+    </Media>
+    <Media Include="WAVE\test1.wav">
+      <Filter>Resource Files</Filter>
+    </Media>
+    <Media Include="WAVE\test2.wav">
       <Filter>Resource Files</Filter>
     </Media>
   </ItemGroup>

BIN
WAVE/Crystal.wav


BIN
WAVE/enemy.wav


BIN
WAVE/ghostEnemy.wav


+ 3 - 3
worlds/small.json

@@ -24,17 +24,17 @@
       "file": "models/squid/Blooper.obj",
       "pos": [ 20, 5, 10 ],
       "scale": 0.01,
-      "music": "WAVE/enemy.wav"
+      "music": "WAVE/ghostEnemy.wav"
     },
     {
       "file": "models/squid/Blooper.obj",
       "pos": [ 30, 10, 10 ],
       "scale": 0.01,
-      "music": "WAVE/enemy.wav"
+      "music": "WAVE/ghostEnemy.wav"
   }],
   "crystal": {
     "full texture": "models/crystal/Crystal.obj",
-    "empty texture": "models/crystal/PickedUpCrystal.obj",
+	"empty texture": "models/crystal/PickedUpCrystal.obj",
     "instances": [
       {
         "pos": [ 31, 5, 33 ],