コード例 #1
0
ファイル: hashMap.c プロジェクト: KajalJadhav/DSA
void assignAllSlots(ArrayList *list){
	int counter = 0;
	while(counter < list->capacity){
		add(list, createSlot());
		counter++;
	}
}
コード例 #2
0
	FPSCamera::FPSCamera()
		:Object(),mPitch(0)
	{
		createSlot("look",this,&FPSCamera::look);
		EventHandler::getDestination("OISSubsystem")->getSignal("mouseMoved")
			->addListener(getSlot("look"));
    createSignal("moved");

		mOgre = Engine::getPtr()->getSubsystem("OgreSubsystem")->castType<OgreSubsystem>();
		mOIS = Engine::getPtr()->getSubsystem("OISSubsystem")->castType<OISSubsystem>();

		mCamera = mOgre->createCamera();
		mCamera->setFarClip(1000.f);
		mCamera->setNearClip(0.1f);
		mOgre->setActiveCamera(mCamera);

		mRollNode = mOgre->createSceneNode();
		mYawNode = mOgre->createSceneNode();
		mPitchNode = mOgre->createSceneNode();
		mPosNode = mOgre->createSceneNode();
		mOriNode = mOgre->createSceneNode();

		mOgre->getRootSceneNode()->addChild(mPosNode);
		mPosNode->addChild(mOriNode);
		mOriNode->addChild(mYawNode);
		mYawNode->addChild(mPitchNode);
		mPitchNode->addChild(mRollNode);
		mRollNode->addChild(mCamera);

		mCamera->setFOV(75.f);
	}
コード例 #3
0
ファイル: Enemy.cpp プロジェクト: LudumDareGames/RileyA-LD26
Enemy::Enemy(Vector3 startpos) {
  bob = 0;
	mGfx = dynamic_cast<OgreSubsystem*>(Engine::getPtr()->getSubsystem("OgreSubsystem"));
	mPhysics = dynamic_cast<BulletSubsystem*>(Engine::getPtr()->getSubsystem("BulletSubsystem"));
  m_mesh = mGfx->createMesh("Enemy.mesh");
  for (int i = 0; i < 5; ++i) {
    m_minis.push_back(new MiniEnemy(this));
  }
  bs = mGfx->createBillboardSet("AUTO_NAME_ME");
  bs->addBillboard(Vector3(0,0,0), 10, 10);
  bs->setMaterialName("enemy_glow");
  mGfx->getRootSceneNode()->addChild(m_mesh);
  m_mesh->addChild(bs);
  light = mGfx->createLight();
  m_mesh->addChild(light);
  light->addChild(mGfx->createMesh("SpotBeam.mesh"));
  light->setDirection(Vector3(0,-1,0));
  light->pitch(20.0);

  m_dir = Vector3(0,0,-1);
  startpos.y = 20;
  m_pos = startpos;

  m_state = ES_WAIT;
  waitTimer = 10.f;
  m_path = new Spline();
  createSlot("playerMoved",this,&Enemy::playerMoved);
  los_time = 0;
  ammo_timer = 0.f;
}
コード例 #4
0
ファイル: IHLobbyState.cpp プロジェクト: RileyA/IslandHopping
	void LobbyState::init()
	{
		mGfx = dynamic_cast<OgreSubsystem*>(mEngine->getSubsystem("OgreSubsystem"));
		mAudio = dynamic_cast<ALSubsystem*>(mEngine->getSubsystem("ALSubsystem"));
		mInput = dynamic_cast<OISSubsystem*>(mEngine->getSubsystem("OISSubsystem"));
		mScript = dynamic_cast<LuaSubsystem*>(mEngine->getSubsystem("LuaSubsystem"));
		mInput->initInput(mGfx->getWindowHandle(), true);
		mGfx->setBackgroundColor(Colour(0.3f,0.5f,0.7f));

		GUI* gui = mGfx->getGUI();
		GUIScreen* scrn = mGfx->getGUI()->createScreen(mGfx->getMainViewport(),"TechDemo","Test");
		mScreen = scrn;
		scrn->getRootElement(0)->setAspectRatio(4,3);
		mGfx->getGUI()->setOverlayEnabled("HUD", false);

		// set up cursor
		GUIRectangle* rect = new GUIRectangle(scrn->getRootElement(8),"cursor","Mouse");
		rect->setScale(Vector2(16.f/1024.f,23.f/768.f));
		scrn->setCursor(rect);

		// hook up the input and the GUI
		EventHandler::getDestination("OISSubsystem")->getSignal("mouseMovedAbs")
			->addListener(scrn->getSlot("moveCursor"));
		EventHandler::getDestination("OISSubsystem")->getSignal("pressed_MB_Left")
			->addListener(scrn->getSlot("click"));
		EventHandler::getDestination("OISSubsystem")->getSignal("released_MB_Left")
			->addListener(scrn->getSlot("release"));

		StaticText* txt = new StaticText(scrn->getRootElement(0),
			"Title",0,20,Vector2(0.4f,0.2f),Vector2(0.2,1.f/20.f),"New Game");
		createSlot("play", this, &LobbyState::clickedStart);
		txt->setColour(Colour(1.f,1.f,1.f));
		txt->setAlign(GA_CENTER);

		rect = new GUIRectangle(scrn->getRootElement(0),"button","logo");
		rect->setScale(Vector2(327.f/1024.f,80.f/768.f));
		rect->setPosition(Vector2(-0.01f,0.9f));

		// labels
		txt = new StaticText(scrn->getRootElement(0),"modelabel",0,20,Vector2(0.4f,0.27f),
			Vector2(0.2,1.f/20.f),"Mode: ");
		txt->setColour(Colour(1.f,1.f,1.f));
		txt->setScale(Vector2(327.f/1024.f,32.f/768.f));
		txt->setPosition(Vector2(0.2705f,0.492f));
		txt = new StaticText(scrn->getRootElement(0),"difflabel",0,20,Vector2(0.4f,0.27f),
			Vector2(0.2,1.f/20.f),"Difficulty: ");
		txt->setColour(Colour(1.f,1.f,1.f));
		txt->setScale(Vector2(327.f/1024.f,32.f/768.f));
		txt->setPosition(Vector2(0.2705f,0.552f));

		addButton(Vector2(412.f/1024.f, 0.4f), "Go!", "play");
		addButton(Vector2(412.f/1024.f, 0.48f), "< Classic >", "play");
		addButton(Vector2(412.f/1024.f, 0.54f), "< Easy >", "play");
		addButton(Vector2(412.f/1024.f, 0.62f), "Back", "play");



	}
コード例 #5
0
// GameServer constructor
GameServer::GameServer()
{
   // Set the function for bad new call
   set_new_handler(badNew);

   // Open the input slot
   hInputSlot = createSlot(-1);

   if ( hInputSlot == INVALID_HANDLE_VALUE )
      exit(0);

   // Initialize all nodes to NULL.
   for ( int n = 0; n < MAX_NODE; n++ )
      {
      gNode[n] = NULL;
      }

   // Initialize the game's CRITICAL_SECTION object.
   InitializeCriticalSection(&csCritical);
      
   nCriticalCount = 0;
   nPlayersInGame = 0;
}
コード例 #6
0
ファイル: GUIBatch.cpp プロジェクト: 67-6f-64/OryxEngine
	Batch::Batch(Oyster::Batch* b)
		:GUIElement(0),mOysterBatch(b),mWidth(b->getWidth()),mHeight(b->getHeight())
	{
		createSignal("update");
		createSignal("clickUp");
		createSignal("mouseMoved");

		mHovered = 0;
		mClicked = 0;

		mBatch = this;
		mCursor = 0;//new Empty(this, 9001);// the layer is OVER NINE THOUSAND (aka, it's always on top)
		//addChild(mCursor);
	
		createSlot("mouseMoved", this, &Batch::mouseMoved);
		createSlot("mouseUp", this, &Batch::mouseUp);
		createSlot("mouseDown", this, &Batch::mouseDown);
		createSlot("keyUp", this, &Batch::keyUp);
		createSlot("keyDown", this, &Batch::keyDown);
		createSlot("charUp", this, &Batch::charUp);
		createSlot("charDown", this, &Batch::charDown);
	}
コード例 #7
0
ファイル: PlayState.cpp プロジェクト: RileyA/RGJ06
		tt = new StaticText(gameover,
			"Title",0,20,Vector2(0.2f,0.55f),Vector2(0.6,1.f/20.f),"Press ENTER to play again.");
		tt->setAlign(GA_CENTER);

		tt = new StaticText(gameover,
			"Title",0,20,Vector2(0.2f,0.6f),Vector2(0.6,1.f/20.f),"Or ESC to quit.");
		tt->setAlign(GA_CENTER);

		mPlayerPos = Vector3(0,0,0);
		
		mTunnel = new SplineTunnel();
		mCamera = new FPSCamera();

		EventHandler::getDestination("OISSubsystem")->getSignal("mouseMoved")
			->addListener(createSlot("mouseMoved",this,&PlayState::mouseMove));
		mTunnel->getSignal("hitLaser")->addListener(createSlot("hitLaser",this,&PlayState::hitLaser));
		mTime = 0.f;
	}
	//-----------------------------------------------------------------------
	
	void PlayState::update(Real delta)
	{
		if(!music.isActive())
		{
			music = mAudio->play2D("../media/audio/Anamanaguchi_-_03_-_Airbase.ogg");//.getData().mLooping = true;
		}
		if(!mGameOver)
		{
			mTime+=delta;
コード例 #8
0
BulletManager::BulletManager(QEngine* engine,String bucket,String name)
    :LogicObject(engine,bucket,name)
{
    createSlot("fire",fastdelegate::MakeDelegate(this,&BulletManager::fireShot));
}
コード例 #9
0
void PlayState::init()
{
	srand(time(0));

	// grab pointers to e'rythang
	mGfx = dynamic_cast<OgreSubsystem*>(mEngine->getSubsystem("OgreSubsystem"));
	mAudio = dynamic_cast<ALSubsystem*>(mEngine->getSubsystem("ALSubsystem"));
	mInput = dynamic_cast<OISSubsystem*>(mEngine->getSubsystem("OISSubsystem"));
	mGUI = dynamic_cast<GUISubsystem*>(mEngine->getSubsystem("GUISubsystem"));
	mPhysics = dynamic_cast<BulletSubsystem*>(mEngine->getSubsystem("BulletSubsystem"));

	// start up input, grab the mouse
	mInput->initInput(mGfx->getWindowHandle(), true);

	// start up bullet for collision detection
	mPhysics->startSimulation();

	// a dark background color helps hide momentary gaps, that may occur when blocks are
	// changed on edges, and one chunk updates before the other
	Colour col = Colour(255/255.f,200/255.f,158/255.f);
	Colour col2 = Colour(211/255.f,234/255.f,243/255.f);
	mGfx->setBackgroundColor(col2);
	mGfx->setLinearFog(30.f,60.f,col);

	// enable portal stencil hack with 3 visual recursions
	mGfx->enablePortalHack(3);
	
	// so we can get signals during portal rendering (for setting up camera, visibility, etc)
	mGfx->getSignal("updateCam")->addListener(createSlot("updateCam", this, &PlayState::updateCam));

	// standard FPS-style camera (no character controller just yet)
	mCam = new FPSCamera();

	// make the portals
	mPortals[0] = new Portal(Vector3(-6.5f,-7,-3.f), BD_BACK, BD_UP, true);
	mPortals[1] = new Portal(Vector3(-6.5f,-7,3), BD_LEFT, BD_UP, false);

	// quick and ugly hack for light through portals
	mPortals[0]->chunks[0] = 0;
	mPortals[0]->chunks[1] = 0;
	mPortals[1]->chunks[0] = 0;
	mPortals[1]->chunks[1] = 0;
	mPortals[0]->lightVals[0] = 0;
	mPortals[0]->lightVals[1] = 0;
	mPortals[1]->lightVals[0] = 0;
	mPortals[1]->lightVals[1] = 0;
	mPortals[0]->placed = 0;
	mPortals[1]->placed = 0;

	// connect them (eventually I'd like to allow any number of portal pairs, but for now
	// everythings very hacky and hardcoded to do two portals...
	mPortals[0]->setSibling(mPortals[1]);
	mPortals[1]->setSibling(mPortals[0]);

	// Set up chunk rendering stuffs
	mChunkMgr = new ChunkManager();
	mGen = new TerrainChunkGenerator();
	mGen->setPlayerPos(Vector3(0,0,0));
	mChunkMgr->init(Vector3(0,0,0), mGen);

	// set up debug overlay
	Batch* b = mGUI->createBatch("test", "TechDemo.oyster");
	
	Caption* c = new Caption(b, 0);
	c->setCaption("Worker threads: 6");
	c->setPosition(Vector2(0.01f, 0.94f));

	c = new Caption(b, 0);
	c->setCaption("Portal Depth: 3");
	c->setPosition(Vector2(0.01f, 0.89f));

	c = new Caption(b, 0);
	c->setCaption("FPS: 60");
	c->setPosition(Vector2(0.01f, 0.69f));
	mFpsText = c;

	c = new Caption(b, 0);
	c->setCaption("Batches: 0");
	c->setPosition(Vector2(0.01f, 0.74f));
	mBatchCountText = c;

	c = new Caption(b, 0);
	c->setCaption("Generated Chunks: 125");
	c->setPosition(Vector2(0.01f, 0.79f));
	mGeneratedChunkCountText = c;

	c = new Caption(b, 0);
	c->setCaption("Active Chunks: 27");
	c->setPosition(Vector2(0.01f, 0.84f));
	mActiveChunkCountText = c;

	c = new Caption(b, 0);
	c->setCaption("Block: 1");
	c->setPosition(Vector2(0.8f, 0.94f));
	mSelectionText = c;

	mBlockSelected = 2;

	// hook it up with the rendering system
	mUI = mGfx->createScreenMesh("UITEST");
	b->getSignal("update")->addListener(mUI->getSlot("update"));
	mUI->setHidden(false);

	//mCam->slerpTime = -10.f;
}
コード例 #10
0
ファイル: door.cpp プロジェクト: evanelias/tournament-trivia
void main(int argc, char *argv[])
#endif
{
   char szText[160];
   bool bSuccess;
   short nTries = 0;

   // Set results of what happens when a call to new fails
   set_new_handler(badNew);

   // Call the startup function
   #ifdef OD32
   startup(lpszCmdLine);
   #else
   startup(argc, argv);
   #endif

   Sleep(500);

   do
      {
      // Attempt to start up the door server process.  (No need to check if the door server process is already
      // running; it does that on its own and shuts down extra copies as needed)
      bSuccess = CreateProcess(DOOR_SERVER_EXE, NULL, NULL, NULL, false, DETACHED_PROCESS, NULL, NULL, new STARTUPINFO, new PROCESS_INFORMATION);
      Sleep(1000);
      nTries++;
      }  
   while ( bSuccess == false && nTries < 5 );

   // Get a handle on the door server's input mailslot
   hInputSlot = openSlot(-1);

   // Create this node's output mailslot.
   hOutputSlot = createSlot( getNode() );
 
   // If unable to open input slot, re-try up to 5 times (intial failure seems to happen on WinXP randomly)
   // If still failure, this indicates the door server is not running and could not be started, so shut down.
   nTries = 0;
   while (hInputSlot == INVALID_HANDLE_VALUE ) 
      {
      Sleep(500);
      hInputSlot = openSlot(-1);      
      if ( ++nTries > 5 )
         {
         local("Unable to start door: IPC error");
         exitDoor(1);
         }
      }

   // If the output slot for this node is already open, it means the node is already running the door.
   if ( hOutputSlot == INVALID_HANDLE_VALUE )
      {
      local("Unable to start door:  This node is already in use!");
      pausePrompt();
      exitDoor(1);
      }

   // Now that the mailslot handles were successful, call setupExitFunction() to register beforeExit() as the
   // function called upon exit.
   setupExitFunction();
      
   // Send an input message to the server, to tell it a user is trying to enter the game.  The user's info is
   // passed as a string in the format below.
   sprintf(szText, "%d&%c&%d&%s&%s", isSysop(), getGender(), getPlatform(), getAlias(), getRealName());
   sendInput(szText, IP_ENTER_GAME);

   // Handle I/O for the user
   while (1)
      {
      performIO();
      }   
}