Ejemplo n.º 1
0
BOOL CVisualTree::MakeConnector(CVisualPin* pSourcePin, CVisualPin* pSinkPin)
{
    HRESULT hr = S_OK;
    
    CVisualConnector* pVisualConnector = new CVisualConnector;
    CHECK_ALLOC( pVisualConnector );
    
    AddVisual(pVisualConnector);
        
    pVisualConnector->Left() = pSourcePin->GetConnectorPoint();
    pVisualConnector->Right() = pSinkPin->GetConnectorPoint();
    pSourcePin->SetConnector(pVisualConnector);
    pSinkPin->SetConnector(pVisualConnector);
    
Cleanup:
    if(FAILED(hr))
    {
        return FALSE;
    }
    
    return TRUE;
}
Ejemplo n.º 2
0
  //everything!
  void Engine::Step(double _fps, bool _input[256], long mouse, long long _nFrameCount)
  {

    if (RunOnce){

      //Sprite* sp = new Sprite(pResourceMan);

      x = 100; y = 100;
      
      Player = new Entity();

      /*
      mousex = LOWORD(mouse);
      mousey = HIWORD(mouse);
      prevmousex = mousex;
      prevmousey = mousey;
      */

      ControllerFactory::Instance()->
        CreateController([](Entity* e) -> int {
          auto p = e->GetSprite()->GetPosition();
          p.y+=10;
          p.x++;
          e->GetSprite()->SetPosition(p);
          return 0;
      })->AssignEntity(Player);

      auto PlayerSprite = new Sprite<Texture>();
      auto tex = pResourceMan->Aquire<Texture>("Player1", L"D:\\DEV\\Reimu\\data_character_reimu_attackA000.png");
      pRenderer->BuildTexture(tex);
      PlayerSprite->AddVisual(tex);
      Player->AssignSprite(PlayerSprite);


      //pEntityMan->AddEntity(Player); 
      pEntityMan->AddDrawableEntity(Player); //add entity to game

      /*
      Controller<Entity>* a = ControllerFactory<Entity>::Instance()->CreateController([](Entity* e) -> int {

      return 0;
      });
      */




      pRenderer->Begin3D();

      RunOnce = false;
    }
    ///---------------------------------------//// END INIT PHASE

    //  camz = Player->getPos().y;
    //  camx = Player->getPos().x - 10;


    fps = _fps;
    input = _input;
    nFrameCount = _nFrameCount;

    /*
    prevmousex = pRenderer->getWidth() / 2;
    prevmousey = pRenderer->getHeight()/ 2;
    mousex = LOWORD(mouse) - prevmousex + 8;
    mousey = HIWORD(mouse) - prevmousey + 30;
    */
    /// mousex = ((mousex / ((pRenderer->getWidth() - 30) / 2)) - 1.0112);
    /// mousey = ((mousey / ((pRenderer->getHeight() + 30) / 2)) - 1 + 0.12f);

    //Console toggle
    if (input[192]){
      if (! pConsole->getToggle()){
        pConsole->On();
      } else
        pConsole->Off();

      input[192] = false;
    }

    if (!pConsole->getToggle()){
      if (input['A']){
        float xrotrad, yrotrad;
        yrotrad = ((camroty - 90) / 180 * 3.141592654f);
        camx += float(sin(yrotrad)) ;
        camz -= float(cos(yrotrad)) ;
        x -= 10;
      }
      if (input['D']){
        float xrotrad, yrotrad;
        yrotrad = ((camroty + 90) / 180 * 3.141592654f);
        camx += float(sin(yrotrad)) ;
        camz -= float(cos(yrotrad)) ;
        x += 10;
      }

      if (input['W']){
        // pRenderer->CamTranslate(0,0,1);
        float xrotrad, yrotrad;
        yrotrad = (camroty / 180 * 3.141592654f);
        xrotrad = (camrotx / 180 * 3.141592654f); 
        camx += (float(sin(yrotrad)) * cos(xrotrad));
        camz -= (float(cos(yrotrad)) * cos(xrotrad));
        camy -= float(sin(xrotrad)) ;
        y -= 10;
      }

      if (input['S']){
        // pRenderer->CamTranslate(0,0,-1);
        float xrotrad, yrotrad;
        yrotrad = (camroty / 180 * 3.141592654f);
        xrotrad = (camrotx / 180 * 3.141592654f); 
        camx -= (float(sin(yrotrad)) * cos(xrotrad));
        camz += (float(cos(yrotrad)) * cos(xrotrad));
        camy += float(sin(xrotrad)) ;
        y += 10;
      }

      //pRenderer->CamRotate(mousex * 5, 0,1,0);
      /*
      camroty += mousex / 4;
      if (camroty > 360) camroty -= 360;
      if (camroty < 0) camroty += 360;
      camrotx += mousey / 4;
      if (camrotx > 90) camrotx = 90;
      if (camrotx < -90) camrotx = -90;
      /// pRenderer->CamRotate(mousey - prevmousey, 1,0,0);
      */
    }else{
      pConsole->Input(input);
    }

    //  Player->InputBuffer->pushInput(input);

    pEntityMan->Run();

    //Cleanup Phase ------------------------------------------------------/////
    //Auto Garbage collection?!? in my c++?!?
    ControllerFactory::Instance()->GarbageCollect(); 
  }