Beispiel #1
0
bool Camera3::checkPillarCollision(float moveX, float moveZ) // used to check collision for objects
{
	for (vector<CollisionObject>::iterator it = Pillars->begin(); it != Pillars->end(); ++it)
	{
		if (checkCircleCollision(it->position, it->circleRange, moveX, moveZ))
		{
			return true;
		}
	}

	return false;
}
Beispiel #2
0
bool ofxCirclePacker :: checkCircleCollisionWithNeighbours ( Circle& c1 )
{
	for( int i=0; i<c1.neighbours.size(); i++ )
	{
		Circle& c2 = *c1.neighbours[ i ];
		
		if( checkCircleCollision( c1, c2 ) )
		{
			return true;
		}
	}
	
	return false;
}
Beispiel #3
0
bool ofxCirclePacker :: checkCircleCollisionWithAll ( Circle& c1 )
{
	for( int i=0; i<circles.size(); i++ )
	{
		Circle& c2 = circles[ i ];
		
		if( checkCircleCollision( c1, c2 ) )
		{
			return true;
		}
	}
	
	return false;
}
Entity *Entity::checkCollisions(std::list<Entity *>& e)
{
   std::list<Entity *>::iterator it;

   for (it = e.begin(); it != e.end(); it++) {
      Entity *entity = *it;
      if (entity == this || !entity->getDestructable())
         continue;
      float ex = entity->getX();
      float ey = entity->getY();
      float er = entity->getRadius();
      if (checkCircleCollision(ex, ey, er, x, y, radius))
         return entity;
   }

   return 0;
}
Beispiel #5
0
/*
	Name:	checkCollisions
	Desc:	checks to see if the player has hit any balls on the screen and if so, removes them and creates the
			related reactions, such as adding point, creating a reaction animation and creating a sound effect
	Args:	None
	Rtrn:	None
*/
void Game::checkCollisions()
{
	for(DListIterator<Ball> i = m_obstacles.GetIterator(); i.Valid(); i.Forth())
	{
		if(checkCircleCollision(m_player.getCircle(), i.Item().getCircle()))
		{
			int currentHue = i.Item().getHue() % 300;
			if( (currentHue - m_objectiveHue) <= 60 && (currentHue - m_objectiveHue)  >= -60)
				m_player.setMultiplier(m_player.getMultiplier() + 1);
			else
				m_player.setMultiplier(1);	//Back to deafault.

			m_obstacleReactions.Append(AnimatedBall(i.Item().getCircle().getPosition(), sf::Color(i.Item().getColor())));
			m_player.getParticleSys().setColor(i.Item().getColor());
			m_obstacles.Remove(i);

			m_player.addPoints(m_pointsPerBall);
			m_ballBreak.play();
		}
	}
}
Beispiel #6
0
void Camera3::Update(double dt,int gameState)
{
	if (OnControls)
	{
		static const float WALKSPEED = 5.f; // walkspeed
		static const float CAMERA_SPEED = 50.f;

		JetPack(dt);

		if (isFlyingOn == false)
		{
			if (JUMPING == false)
			{
				if (position.y > 0.f)
				{
					position.y -= 10.f * dt;
				}
				else
				{
					position.y = 0.f;
				}
			}
			if (JUMPING == true)
			{
				if (JUMPING_UP == true && JUMP_SPEED > 0.f)
				{
					position += Vector3(0.f, JUMP_SPEED * dt, 0.f);
					JUMP_SPEED -= 10 * dt;
					if (JUMP_SPEED <= 0.f)
					{
						JUMPING_UP = false;
					}
				}
				if (JUMPING_UP == false && JUMP_SPEED < 10.f)
				{
					position -= Vector3(0.f, JUMP_SPEED * dt, 0.f);
					JUMP_SPEED += 10 * dt;
					if (JUMP_SPEED >= 10.f)
					{
						JUMPING_UP = true;
						JUMPING = false;
					}
				}
				if (position.y < 0.f)
				{
					position.y = 0.f;
				}
			}
		}

		//movement keys are now geood
		if (Application::IsKeyPressed('A') || Application::IsKeyPressed('D') || Application::IsKeyPressed('W') || Application::IsKeyPressed('S'))
		{
			float moveX = 0, moveZ = 0;
			if (Application::IsKeyPressed('A'))
			{
				moveX += -right.x*(WALKSPEED)*dt;
				moveZ += -right.z*(WALKSPEED)*dt;

			}
			if (Application::IsKeyPressed('D'))
			{
				moveX += right.x*(WALKSPEED)*dt;
				moveZ += right.z*(WALKSPEED)*dt;

			}
			if (Application::IsKeyPressed('W'))
			{
				view = (Vector3(target.x, 0.f, target.z) - Vector3(position.x, 0.f, position.z)).Normalized();
				moveX += view.x*(WALKSPEED)*dt;
				moveZ += view.z*(WALKSPEED)*dt;

			}
			if (Application::IsKeyPressed('S'))
			{
				view = (Vector3(target.x, 0.f, target.z) - Vector3(position.x, 0.f, position.z)).Normalized();
				moveX += -view.x*(WALKSPEED)*dt;
				moveZ += -view.z*(WALKSPEED)*dt;

			}
			if (gameState == 0 || gameState == 1)
			{
				if (!checkRockCollision(moveX + position.x, position.z) && !checkCircleCollision(flag->position, 1.f, moveX + position.x, position.z))
				{
					position.x += moveX;
				}
				if (!checkRockCollision(position.x, moveZ + position.z) && !checkCircleCollision(flag->position, 1.f, position.x, moveZ + position.z))
				{
					position.z += moveZ;
				}
			}
			else if (gameState == 2)
			{
				if (!checkRockCollision(moveX + position.x, position.z) && !checkCircleCollision(Vector3(0,0,0), 18.5f, moveX + position.x, position.z))
				{
					position.x += moveX;
				}
				if (!checkRockCollision(position.x, moveZ + position.z) && !checkCircleCollision(Vector3(0, 0, 0), 18.5f, position.x, moveZ + position.z))
				{
					position.z += moveZ;
				}
			}
			else if (gameState == 3)
			{
				if (!checkRockCollision(moveX + position.x, position.z) && !checkReverseCircleCollision(Vector3(0, 0, 0), 69.f, moveX + position.x, position.z)
					&& !checkPillarCollision(moveX + position.x, position.z))
				{
					position.x += moveX;
				}
				if (!checkRockCollision(position.x, moveZ + position.z) && !checkReverseCircleCollision(Vector3(0, 0, 0), 69.f, position.x, moveZ + position.z)
					&& !checkPillarCollision(position.x, moveZ + position.z))
				{
					position.z += moveZ;
				}
			}
		}
		if (Application::IsKeyPressed(' '))
		{
			if (JUMPING == false && position.y <= 0.f)
			{
				JUMPING = true;
			}
		}

		// boundaries
		float bounds = 100.f;

		if (position.x < -bounds)
		{
			position.x = -bounds;
		}
		else if (position.x > bounds)
		{
			position.x = bounds;
		}

		if (position.z < -bounds)
		{
			position.z = -bounds;
		}
		else if (position.z > bounds)
		{
			position.z = bounds;
		}

		//mouse rotation of camera
		CameraRotation(MouseSensitivity);

		view = (target - position).Normalized();
		right = view.Cross(defaultUp);
		right.y = 0;
		right.Normalize();
		this->up = right.Cross(view).Normalized();
	}
}