예제 #1
0
	void AsteroidManager::splitAsteroid(Asteroid* aAsteroid) {

		std::vector<Asteroid*>::iterator itr = iAsteroids.begin();
		for (; itr != iAsteroids.end(); itr++) {
			if ((*itr) == aAsteroid) {
				break;
			}
		}

		//Found aAsteroid in iAsteroids
		if (itr != iAsteroids.end()) {
			Asteroid* asteroidMatch = (*itr);

			if (asteroidMatch == nullptr) {
				printf ("Error! asteroidMatch %p is null; Cannot complete split! Ignoring operation...\n", aAsteroid);
				return;
			}

			iAsteroids.erase(itr);

			if (asteroidMatch == nullptr) {
				printf ("Error! Erase f***s with the pointer :/ \n", aAsteroid);
				return;
			}

			int newTier = asteroidMatch->getTier() - 1;

			//Only create smaller pieces if split asteroid is big enough
			if (newTier > 0) {
				Ogre::Vector3 newDirection = iApplication->generateRandomVector3();

				Asteroid* splitA = createAsteroid(newTier, newDirection);
				Asteroid* splitB = createAsteroid(newTier, -newDirection);

				placeAsteroid(splitA, asteroidMatch->getNode()->getPosition() + newDirection);
				placeAsteroid(splitB, asteroidMatch->getNode()->getPosition() + newDirection);

				splitA->setSpeed(asteroidMatch->getSpeed() * 1.5);
				splitB->setSpeed(asteroidMatch->getSpeed() * 1.5);

				splitA->setInvulnTimer(3.0f);
				splitB->setInvulnTimer(3.0f);

				iAsteroids.push_back(splitA);
				iAsteroids.push_back(splitB);
			}

			delete asteroidMatch;
		}
		//Didn't find matching asteroid (shouldn't happen)
		else {
			printf ("Error! Couldn't find Asteroid %p in iAsteroids to split! Ignoring operation...\n", aAsteroid);
			return;
		}
	}
예제 #2
0
//---------------------------------------------------------------------------
int GameScreen::getPositions(float * positions)
{
	Ogre::Vector3 pos = ship->getPos();
	positions[0] = pos.x;
	positions[1] = pos.y;
	positions[2] = pos.z;
	Ogre::Quaternion rot = ship->getNode()->getOrientation();
	positions[3] = rot.w;
	positions[4] = rot.x;
	positions[5] = rot.y;
	positions[6] = rot.z;

	pos = alien->getPos();
	positions[7] = pos.x;
	positions[8] = pos.y;
	positions[9] = pos.z;
	rot = alien->getNode()->getOrientation();
	positions[10] = rot.w;
	positions[11] = rot.x;
	positions[12] = rot.y;
	positions[13] = rot.z;

	pos = paddle->getPos();
	positions[14] = pos.x;
	positions[15] = pos.y;
	positions[16] = pos.z;
	rot = paddle->getNode()->getOrientation();
	positions[17] = rot.w;
	positions[18] = rot.x;
	positions[19] = rot.y;
	positions[20] = rot.z;

	std::deque<GameObject*> oList = *(sim->getObjList());
	int astIndex = 3;
	for(int i = 21; i < 21+7*NUM_ASTEROIDS; i+=7, astIndex++){
		Asteroid* ast = (Asteroid*)oList[astIndex];
		pos = ast->getPos();
		positions[i] = pos.x;
		positions[i+1] = pos.y;
		positions[i+2] = pos.z;
		rot = ast->getNode()->getOrientation();
		positions[i+3] = rot.w;
		positions[i+4] = rot.x;
		positions[i+5] = rot.y;
		positions[i+6] = rot.z;
	}

	return (21+7*NUM_ASTEROIDS)*sizeof(float);
}
예제 #3
0
//---------------------------------------------------------------------------
void GameScreen::updateClient(const Ogre::FrameEvent &evt, float * positions)
{
	ship->setPosition(positions[0], positions[1], positions[2]);
	ship->getNode()->setOrientation(Ogre::Quaternion(positions[3],positions[4],positions[5],positions[6]));
	alien->setPosition(positions[7], positions[8], positions[9]);
	alien->getNode()->setOrientation(Ogre::Quaternion(positions[10],positions[11],positions[12],positions[13]));
	alien->setCam(positions[7], positions[8] + 25, positions[9] + 40, positions[7], positions[8], positions[9] - 25);
	alien ->setLight(positions[7], positions[8] + 500, positions[9] + 250);
	paddle->setPosition(positions[14], positions[15], positions[16]);
	paddle->getNode()->setOrientation(Ogre::Quaternion(positions[17],positions[18],positions[19],positions[20]));
	
	std::deque<GameObject*> oList = *(sim->getObjList());
	int astIndex = 3;
	for(int i = 21; i < 21+7*NUM_ASTEROIDS; i+=7, astIndex++){
		Asteroid* ast = (Asteroid*)oList[astIndex];
		ast->setPosition(positions[i], positions[i+1], positions[i+2]);
		ast->getNode()->setOrientation(Ogre::Quaternion(positions[i+3],positions[i+4],positions[i+5],positions[i+6]));
	}

}