Game::Game() : enemyField(ENEMY_FIELD_SIZE), fighterLine(line3df(FIGHTER_LINE_SIZE)), enemies(new EnemyHolder()), fighter(new Fighter()), rockets(new RocketHolder()), gui(new GUI()), effects(new Effect()), texManager(new TextureManager()), engine(new Irrlicht(L"Space Battle", dimension2du(WINDOW_WIDTH, WINDOW_HEIGHT))), state(MENU), sound(createIrrKlangDevice()), score(0), soundPlay(true) { srand(time(NULL)); }
MySound::MySound() { this->engine = createIrrKlangDevice(); if (!engine) { std::cerr << "Oh dear the sound engine did not start up" << std::endl; // error starting up the engine } //engine->play2D("../dependencies/irrKlang/media/Sinner Monologues.wav", false, false, true); // Play something on loop for background music //this->openBckGrnd = engine->play2D("../dependencies/irrKlang/media/ope.wav", false, true, true); //this->openBckGrnd->setVolume(.05); //this->openBckGrnd->setSoundStopEventReceiver(myReceiver, 0); //this->openBckGrnd->setIsPaused(false); this->backGroundSnd = engine->play2D("../dependencies/irrKlang/media/red_sky_at_night.wav", true, true, true); this->backGroundSnd->setVolume(.05); this->noseSnd = engine->play2D("../dependencies/irrKlang/media/ow_my_nose.wav", false, true, true); this->noseSnd->setVolume(.7); this->footSndPlayr = engine->play2D("../dependencies/irrKlang/media/footstepsWalk2.wav", false, true, true); this->guardTalk = engine->play3D("../dependencies/irrKlang/media/killing_to_me.wav", vec3df(0, 0, 0), false, true, true); this->guardTalk->setMinDistance(1.0f); this->loseSnd = engine->play2D("../dependencies/irrKlang/media/endNoise1.wav", false, true, true); this->loseSnd->setVolume(0.5); this->winSnd = engine->play2D("../dependencies/irrKlang/media/end.wav", false, true, true); this->winSnd->setVolume(0.5); this->collectableSnd = engine->play2D("../dependencies/irrKlang/media/collect0.wav", false, true, true); this->collectableSnd->setVolume(0.5); this->openingSnd = engine->play2D("../dependencies/irrKlang/media/intro.wav", false, true, true); this->openingSnd->setVolume(.5); this->leanOut = engine->play2D("../dependencies/irrKlang/media/leanOut.wav", false, true, true); this->leanOut->setVolume(.05); this->leanIn = engine->play2D("../dependencies/irrKlang/media/leanIn.wav", false, true, true); this->leanIn->setVolume(.05); this->reactSnd = engine->play2D("../dependencies/irrKlang/media/guard1_Reac.wav", false, true, true); this->reactSnd->setVolume(0.3); this->dismissSnd = engine->play2D("../dependencies/irrKlang/media/guard1_Dismiss.wav", false, true, true); this->dismissSnd->setVolume(0.3); }
CSound::CSound() : m_Sound_Type(MAIN_MENU) , MainMenu(NULL) , MazeEscaper(NULL) , MCQPower(NULL) , PuzzleParty(NULL) , Stress(NULL) , Lobby(NULL) , volMM(0) , volLob(0) , volME(0) , volMP(0) , volPP(0) , volS(0) , maxVol(1) , active(true) { //create the new sound system TheSound = createIrrKlangDevice(ESOD_AUTO_DETECT, ESEO_MULTI_THREADED | ESEO_LOAD_PLUGINS | ESEO_USE_3D_BUFFERS); }
// Here is where we set up all of the non-rendering stuff (our world, various managers, etc) void OgreTank::createScene() { bgmfile = "background.ogg"; soundEngine = createIrrKlangDevice(); BGM = soundEngine->play2D(bgmfile.c_str(),true, false, true); mInputHandler = new InputHandler(mWindow); mGeometry = new Geometry(mSceneManager, soundEngine); mProjectileManager = new ProjectileManager( mSceneManager, soundEngine, mGeometry); mTankManager = new TankManager(mSceneManager,mProjectileManager, soundEngine, mGeometry); mWorld = new World(mSceneManager, mInputHandler,mTankManager, mProjectileManager, mGeometry); mTankCamera = new TankCamera(mCamera, mCamera2, mWorld, mInputHandler, mTankManager); mUserInput = new UserInput(mInputHandler, mTankManager, mProjectileManager, soundEngine); mWorld->addCamera(mTankCamera); mProjectileManager->addTankManager(mTankManager); }
void initBGMsounds() { engine = createIrrKlangDevice(); PlayThemeSong = engine->addSoundSourceFromFile( SoundName[0].c_str() ); beingChased = engine->addSoundSourceFromFile( SoundName[1].c_str() ); gotExploded = engine->addSoundSourceFromFile( SoundName[2].c_str() ); gateOpening = engine->addSoundSourceFromFile( SoundName[3].c_str() ); hatchOpening = engine->addSoundSourceFromFile( SoundName[4].c_str() ); // The following statements is to ensure that ISound pointer can be used alwaysPlaying = engine->play2D(PlayThemeSong, true, false, true); alwaysPlaying->setVolume(0.7f); beingChasedSnd = 0; gotShotsnd = 0; hatchSnd = 0; }
Game::Game(void){ mouseX = mouseY = 0; camX = 0.0f; camY = 1.0f; camZ = camRad = 1.0f; fCount = 0; physicsState = false; placingWalls = false; wallNumber = 0; isColliding = false; m_sEngine = createIrrKlangDevice(); m_sEngine->play2D("Sounds/Waterflame - Glorious morning.mp3", true); score = -1; gameState = 0; intCalled = false; droppingY = 0.0; tiltX = 0; tiltZ = 0; sphereInZone= false; lives = 3; sphereDensity = 4000; isCollidingModelSphere = false; }
int main( int argc, char **argv) { ISoundEngine* engine = createIrrKlangDevice(); if (!engine) return 0; // error starting up the engine engine->play2D("./musica/pedro.mp3", true); glutInit(&argc,argv); if(init(WIN_POSX,WIN_POSY,WIN_WIDTH,WIN_HEIGHT,"ARM Pedro Infante") == -1){ system("pause"); return -1; } glutDisplayFunc(render); glutIdleFunc(idle); glutReshapeFunc(redimensiona); glutSpecialFunc(keyboardSpec); glutKeyboardFunc(keyboard); glutMouseFunc(mouseClick); glutMotionFunc(mouseDrag); defineLuces(); defineCamaras(); creaEscena(); glutMainLoop(); return 0; }
void Scene::initialiseSound(){ m_sEngine = createIrrKlangDevice(); m_sEngine->setSoundVolume(0.02f); }
Sonido::Sonido() { engine=createIrrKlangDevice(); }
void VRSim::init(){ windowWidth = 1920; windowHeight = 1080; InitLights(); InitColorPalette(); m_gbuffer.Init(windowWidth,windowHeight); geomProgram.init(); //initialize point lights pointProgram.init(); //pointProgram.SetPointLight(m_pointLight[0]); dirProgram.init(); dirProgram.SetDirectionalLight(m_dirLight); //not sure what this is used for m_nullTech.init(); //load models tree.loadModel("./bin/tree/tree.obj"); quad.loadModel("./bin/quad.obj"); sphere.loadModel("./bin/sphere.obj"); pen.loadModel("./bin/objects/Pen.obj"); textpaint.loadModel("./bin/earth.obj"); // Terrain terrain = new Terrain(cavr::math::vec3f(1000,300,1000), "./bin/terrain/output.jpg"); terrain->initialize(); //the origins of time t2 = t1 = std::chrono::high_resolution_clock::now(); time = 0; xValOld = 0.0f; yValOld = 0.0f; boost = rotation = false; cam = Engine::getEngine()->graphics->camera; currentColor = cavr::math::vec3f(1,0,0); cursor.init(); skybox = new Skybox(); // Rui sound engine = createIrrKlangDevice(); // init music name list musicName.push_back("media/A0.wav"); musicName.push_back("media/A1.wav"); musicName.push_back("media/A2.wav"); musicName.push_back("media/A3.wav"); musicName.push_back("media/A4.wav"); musicName.push_back("media/A5.wav"); musicName.push_back("media/A6.wav"); musicName.push_back("media/A7.wav"); // Rui fake gravity sphereRadius = 1; //Build the texture list buttonPress = true; textureindex = 0; TextureBall temp; std::string path = "./bin/whatever.jpg"; if (temp.image.load(path.c_str())) { temp.image.convertTo32Bits(); glGenTextures(1, &temp.id); glBindTexture(GL_TEXTURE_2D, temp.id); glTexImage2D(GL_TEXTURE_2D, 7, GL_RGBA, temp.image.getWidth(), temp.image.getHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *) temp.image.accessPixels()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); textures.push_back(temp); } else { std::cout << "Texture: " << path.c_str() << " failed to load" << std::endl; } //Build the texture list path = "./bin/polkadots.jpg"; if (temp.image.load(path.c_str())) { temp.image.convertTo32Bits(); glGenTextures(1, &temp.id); glBindTexture(GL_TEXTURE_2D, temp.id); glTexImage2D(GL_TEXTURE_2D, 7, GL_RGBA, temp.image.getWidth(), temp.image.getHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *) temp.image.accessPixels()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); textures.push_back(temp); } else { std::cout << "Texture: " << path.c_str() << " failed to load" << std::endl; } }
#include "Game.h" ISoundEngine *SoundEngine = createIrrKlangDevice(); Game::Game(GLuint width, GLuint height) : State(GAME_ACTIVE), Keys(), Width(width), Height(height),Renderer(nullptr),Player(nullptr),Ball(nullptr),Particles(nullptr),Effects(nullptr),ShakeTime(0),Text(nullptr),Lives(3) { } Game::~Game() { delete Renderer; delete Player; delete Ball; delete Particles; delete Effects; delete Text; SoundEngine->drop(); } void Game::Init() { // Load shaders ResourceManager::LoadShader("src/Shader/shader_vertex.vert", "src/Shader/shader_fragment.frag", nullptr, "sprite"); ResourceManager::LoadShader("src/Shader/particle.vert", "src/Shader/particle.frag", nullptr, "particle"); ResourceManager::LoadShader("src/Shader/post_processing.vs", "src/Shader/post_processing.frag", nullptr, "postprocessing"); // Configure shaders glm::mat4 projection = glm::ortho(0.0f, static_cast<GLfloat>(this->Width),
int main(int argc, const char** argv) { /* - deviceType: Type of the device. This can currently be the Null-device, one of the two software renderers, D3D8, D3D9, or OpenGL. In this example we use EDT_SOFTWARE, but to try out, you might want to change it to EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8, EDT_DIRECT3D9, or EDT_OPENGL. */ MyEventReceiver receiver; ISoundEngine* music = createIrrKlangDevice(); IrrlichtDevice *device = createDevice( EDT_DIRECT3D9, dimension2d<u32>(640, 480), 32, false, false, false, &receiver); music->play2D("../media/MUSIC/Dark Impetus.mp3",true,false,true); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); ICameraSceneNode *camera = smgr->addCameraSceneNode(); IGUIFont* font = device->getGUIEnvironment()->getFont("../media/fonthaettenschweiler.bmp"); camera->setFarValue(900); IAnimatedMesh* map = smgr->getMesh(DC_01); IAnimatedMeshSceneNode* mapnode = smgr->addAnimatedMeshSceneNode(map); mapnode->setMaterialFlag(EMF_LIGHTING,false); IAnimatedMesh* player1 = smgr->getMesh(SORA); IAnimatedMeshSceneNode* p1node = smgr->addAnimatedMeshSceneNode(player1); p1node->setMaterialFlag(EMF_LIGHTING, false); p1node->setScale(SORA_VECTOR3D); IAnimatedMesh* player2 = smgr->getMesh(AQUA); IAnimatedMeshSceneNode* p2node = smgr->addAnimatedMeshSceneNode(player2); p2node->setMaterialFlag(EMF_LIGHTING, false); p2node->setScale(NORMAL_VECTOR3D); vector3df Position = p1node->getPosition(); vector3df P2Pos = p2node->getPosition(); vector3df PosCam = p1node->getPosition(); vector3df Rotate = p1node->getPosition(); int CurrentHP = 300; int MaxHP = 400; int HeartP = 10; bool LockOn = false; bool LockCheck = false; stringw CoorCheck; while(device->run()) { CoorCheck +=L"Your position\nX:"; CoorCheck +=Position.X; CoorCheck +=L"\nY:"; CoorCheck +=Position.Y; CoorCheck +=L"\nZ:"; CoorCheck +=Position.Z; CoorCheck +=L"\n\nTarget Position:"; CoorCheck +=P2Pos.X; if(LockCheck != true){ if(receiver.IsKeyDown(KEY_KEY_J)){LockOn = true; LockCheck = true;}} else{ if(receiver.IsKeyDown(KEY_KEY_J)){LockOn = false;LockCheck = false;}} //3D Rendering. MaximizeKey(receiver,device); GetCaption(driver,device); driver->beginScene(true, true, SColor(255,100,101,140)); p1node->setPosition(Position); camera->setPosition(vector3df(PosCam.X,PosCam.Y+2,PosCam.Z+3)); if(LockOn != false){camera->setTarget(P2Pos);} else{camera->setTarget(Position);} smgr->drawAll(); //2D Rendering. if(CurrentHP<=0){font->draw(L"You are dead!!!",rect<s32>(120,140,250,210),SColor(255,255,255,255));} else{if(receiver.IsKeyDown(KEY_KEY_L)){--CurrentHP;}} if(CurrentHP>=MaxHP){}else{if(receiver.IsKeyDown(KEY_KEY_K)){++CurrentHP;}} if(receiver.IsKeyDown(KEY_KEY_N)){++MaxHP;} if(receiver.IsKeyDown(KEY_KEY_M) && CurrentHP<MaxHP){--MaxHP;} if(HeartP>=86){}else{ if(receiver.IsKeyDown(KEY_KEY_F)){++HeartP;}} font->draw (L"Press O for full screen.\nPress Up-Down-Left-right to move.\nPress L to hurt the character.\nPress K to heal the character.\nPress N to increase Max HP.\nPress M to decrease Max HP.\nPress F to fill the Heart gauge.",rect<s32>(20,40,150,110),SColor(255,0,0,0)); font->draw(CoorCheck,rect<s32>(20,140,150,110),SColor(255,0,0,0)); //Button detection. if(receiver.IsKeyDown(KEY_UP)){ Position.Z -= 0.1f; PosCam.Z = Position.Z; p1node->setRotation(vector3df(Rotate.X,Rotate.Y = 0,Rotate.Z)); p1node->setPosition(Position);} if(receiver.IsKeyDown(KEY_DOWN)){ Position.Z += 0.1f; PosCam.Z = Position.Z; p1node->setRotation(vector3df(Rotate.X,Rotate.Y -180,Rotate.Z)); p1node->setPosition(Position);} if(receiver.IsKeyDown(KEY_LEFT)){ Position.X += 0.1f; PosCam.X = Position.X; p1node->setRotation(vector3df(Rotate.X,Rotate.Y -90,Rotate.Z)); p1node->setPosition(Position);} if(receiver.IsKeyDown(KEY_RIGHT)){ Position.X -= 0.1f; PosCam.X = Position.X; p1node->setRotation(vector3df(Rotate.X,Rotate.Y +90,Rotate.Z)); p1node->setPosition(Position);} HUD_Display(device,driver,receiver,font,CurrentHP,MaxHP,HeartP); guienv->drawAll(); CoorCheck = L""; driver->endScene(); } music->drop(); device->drop(); return 0; }
//Starts the background music via the IrrKlang engine void SoundEngine::startBackgroundTrack(){ backgroundTrackSoundEngine = createIrrKlangDevice(); backgroundTrackSoundEngine->play2D("../media/TheForestAwakes.ogg", true); }