Esempio n. 1
0
  App() : mTimer(0), mTimer2(0), mNextUpdate(0)
  {
   
   _makeOgre();
   _makeOIS();

  // Create Silverback and load in dejavu
  mSilverback = new Gorilla::Silverback();
  mSilverback->loadAtlas("dejavu");
  mScreen = mSilverback->createScreen(mViewport, "dejavu");
  mScreen->setOrientation(Ogre::OR_DEGREE_270);
  Ogre::Real vpW = mScreen->getWidth(), vpH = mScreen->getHeight();

  // Create our drawing layer
  mLayer = mScreen->createLayer(0);
  rect = mLayer->createRectangle(0,0, vpW, vpH);
  rect->background_gradient(Gorilla::Gradient_Diagonal, Gorilla::rgb(98,0,63), Gorilla::rgb(255,180,174));
  
  markup = mLayer->createMarkupText(9,5,5, "%@24%A Haiku\n%@14%Written by Betajaen%@9%\nSo many to choose from\nPretty typefaces on Ogre screen\nTime to update Git");
  
  caption = mLayer->createCaption(9, vpW - 55, 5, "9");
  caption->width(50);
  caption->align(Gorilla::TextAlign_Right);

  caption = mLayer->createCaption(14, vpW - 55, 18, "14");
  caption->width(50);
  caption->align(Gorilla::TextAlign_Right);

  caption = mLayer->createCaption(24, vpW - 55, 33, "24");
  caption->width(50);
  caption->align(Gorilla::TextAlign_Right);
  }
Esempio n. 2
0
 void createHUD()
 {
  mHUD = mSilverback->createScreen(mViewport, "dejavu");
  mHUDLayer = mHUD->createLayer();
  
  Gorilla::Caption* fakeHealth = mHUDLayer->createCaption(24, 0, 0, "+ 100");
  fakeHealth->width(mViewport->getActualWidth()-16);
  fakeHealth->height(mViewport->getActualHeight()-4);
  fakeHealth->align(Gorilla::TextAlign_Right);
  fakeHealth->vertical_align(Gorilla::VerticalAlign_Bottom);
  
  Gorilla::Caption* fakeAmmo = mHUDLayer->createCaption(24, 16, 0, ": 60");
  fakeAmmo->width(mViewport->getActualWidth());
  fakeAmmo->height(mViewport->getActualHeight()-4);
  fakeAmmo->vertical_align(Gorilla::VerticalAlign_Bottom);
  
  mCrosshairLayer = mHUD->createLayer();
  mCrosshair = mCrosshairLayer->createRectangle((mViewport->getActualWidth() * 0.5f) - 11, (mViewport->getActualHeight() * 0.5f) - 11, 22, 22);
  mCrosshair->background_image("crosshair");
  
 }
Esempio n. 3
0
  App() : mNextUpdate(0), mTimer(0)
  {
   
   _makeOgre();
   _makeOIS();
   _makeScene();
   
   // Initialise Gorilla
   mGorilla = new Gorilla::Silverback();
   mGorilla->loadAtlas("dejavu");
   mScreen = mGorilla->createScreen(mViewport, "dejavu");
   
   mFPSLayer = mScreen->createLayer(14);
   mFPS = mFPSLayer->createCaption(14, 10,10, Ogre::StringUtil::BLANK);

   mConsole = new OgreConsole();
   mConsole->init(mScreen);
   mConsole->addCommand("whoami", whoami);
   mConsole->addCommand("version", version);
   mConsole->addCommand("make", make);
   mConsole->addCommand("quit", quit);
  }
Esempio n. 4
0
  bool frameStarted(const Ogre::FrameEvent& evt)
  {
   
   if (mWindow->isClosed())
    return false;
   
   mKeyboard->capture();
   if (mKeyboard->isKeyDown(OIS::KC_ESCAPE))
     return false;
   mMouse->capture();
   
   mTimer += evt.timeSinceLastFrame;
   
   if (mTimer > 1.0f / 60.0f)
   {
    mPowerPanel->mNode->yaw(Ogre::Radian(0.0005));
    mTimer2 += Ogre::Math::RangeRandom(0, mTimer * 10);
    mTimer = 0;
    Ogre::Math::Clamp<Ogre::Real>(mTimer2, 0, 25);
    Ogre::Real power = mBasePower + (Ogre::Math::Cos(mTimer2) * 5);
    power = Ogre::Math::Clamp<Ogre::Real>(power, 0, 380);
    mPowerValue->width(power);
   }
   bool isOver = false;
   
   Button* button = mPowerPanel->check( mCamera->getCameraToViewportRay(0.5f,0.5f), isOver );
   if (isOver)
    mCrosshairLayer->hide();
   else
    mCrosshairLayer->show();
     
   if (button != 0 && mMouse->getMouseState().buttonDown(OIS::MB_Left))
   {
    if (button == mPowerDownButton)
    {
     mBasePower -= 1.0f;
    }
    if (button == mPowerUpButton)
    {
     mBasePower += 1.0f;
    }
   }

   Ogre::Vector3 trans(0,0,0);
   
   if (mKeyboard->isKeyDown(OIS::KC_W))
    trans.z = -1;
   else if (mKeyboard->isKeyDown(OIS::KC_S))
    trans.z =  1;
   if (mKeyboard->isKeyDown(OIS::KC_A))
    trans.x = -1;
   else if (mKeyboard->isKeyDown(OIS::KC_D))
    trans.x =  1;
   
   if (trans.isZeroLength() == false)
   {
    Ogre::Vector3 pos = mCamera->getPosition();
    pos += mCamera->getOrientation() * (trans * 5.0f) * evt.timeSinceLastFrame;
    pos.y = 2.0f;
    mCamera->setPosition(pos);
   }
   
   return true;
  }