void ProjectileManager::createExplosion(const Ogre::Vector3& location){
	std::ostringstream oss;
	oss << "Explosion" << time(0) << explosions.size() << counter++;	

	Ogre::ParticleSystem* ps = mSceneMgr->createParticleSystem(oss.str(), "explosionTemplate");
	ps->fastForward(1.0f);

	//scaleBy(0.5f, ps);

	Ogre::Vector3 loc = location;

	loc.y += 10.f;

	Ogre::SceneNode* explosionSn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	explosionSn->attachObject(ps);
	explosionSn->setPosition(loc);
	//explosionSn->scale(Ogre::Vector3(0.1f));
	
	explosions.insert(new Explosion(explosionSn, 1.8f));

	soundPlayer->playExplosionSound();
}
Exemple #2
0
void GameState::createScene() {
  graphics = new Graphics(m_pSceneMgr);
  physics = new Physics(graphics);
  graphics->setPhysics(physics);
  physics->initialize();
  PenguinNode = m_pSceneMgr->getSceneNode("penguin");

  m_pSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
  
  // Create a snowstorm
  Ogre::ParticleSystem* snow = m_pSceneMgr->createParticleSystem("snow", "Examples/Snow");
  Ogre::SceneNode* sNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("snowNode");
  sNode->translate(0, 1200, 2000);
  sNode->attachObject(snow);
  snow->fastForward(100);

  CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
  CEGUI::Window *gameWindow = wmgr.createWindow("DefaultWindow", "CEGUI/GameGUI");

  // penguin portrait
  face = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "FacePng");
  face->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.13, 0)));
  face->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
  face->setProperty("Image","set:Face image:full_image");
  face->setProperty("FrameEnabled", "False");
  face->setProperty("BackgroundEnabled", "False");
  gameWindow->addChildWindow(face);

  // life
  life = wmgr.createWindow("TaharezLook/StaticText", "CEGUI/Life");
  stringstream s;
  s << physics->getLives();
  life->setText("x"+s.str());
  life->setSize(CEGUI::UVector2(CEGUI::UDim(0.04, 0), CEGUI::UDim(0.05, 0)));
  life->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08, 0), CEGUI::UDim(0.048, 0)));
  life->setProperty("FrameEnabled", "False");
  life->setProperty("BackgroundEnabled", "False");
  // life->setProperty("Font", "Jura-18");
  gameWindow->addChildWindow(life);

  // health bar for certain stages
  hp = 1.0f;
  showHealth = false;
  health = wmgr.createWindow("TaharezLook/ProgressBar", "CEGUI/Health");
  health->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.04, 0)));
  health->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08, 0), CEGUI::UDim(0.01, 0)));
  health->setProperty("Visible", "False");
  gameWindow->addChildWindow(health);

  // Pause menu
  pauseWindow = wmgr.createWindow("TaharezLook/StaticText", "CEGUI/PauseWindow");
  pauseWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0.4, 0), CEGUI::UDim(0.35, 0)));
  pauseWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.35, 0)));
  pauseWindow->setProperty("Visible", "False");
  gameWindow->addChildWindow(pauseWindow);

  CEGUI::Window *ret = wmgr.createWindow("TaharezLook/Button", "CEGUI/ReturnToGameButton");
  ret->setText("Resume Game");
  ret->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.2, 0)));
  ret->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.25, 0)));
  pauseWindow->addChildWindow(ret);

  CEGUI::Window *bac = wmgr.createWindow("TaharezLook/Button", "CEGUI/BackToTitleButton");
  bac->setText("Back to Title");
  bac->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.2, 0)));
  bac->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.55, 0)));
  pauseWindow->addChildWindow(bac);
  
  CEGUI::System::getSingleton().setGUISheet(gameWindow);

  // event calls
  ret->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GameState::returnToGame, this));
  bac->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GameState::backToTitle, this));
}