void	PhysicsEngine::Update(float msec) {
	BroadPhaseCollisions();
	NarrowPhaseCollisions();

	for (vector<PhysicsEntity*>::iterator i = allNodes.begin(); i != allNodes.end(); ++i) {
		(*i)->Update(msec);
	}
}
void	PhysicsSystem::Update(float msec) {	


	BroadPhaseCollisions();
	NarrowPhaseCollisions();
	//DeleteCollided();
	for(vector<PhysicsNode*>::iterator i = allNodes.begin(); i != allNodes.end(); ++i) {
		(*i)->Update(msec);
	}
}
示例#3
0
void PhysicsSystem::Update(float msec) {	
	vector<PhysicsNode*> narrowNodes;
	
	BroadPhaseCollisions(narrowNodes);
	NarrowPhaseCollisions(narrowNodes);


	ret->Update(msec);
	bool on = Window::GetMouse()->ButtonDown(MOUSE_LEFT);
	if(on && force<=3000.0f) force+=10.0f * msec;
	
	if(!on && lastclick) {
		lastclick = true;
		SubMessage::ActivateMessage();
	}
	

	for(vector<EnemyEntity*>::iterator i = enemyNodes.begin(); i != enemyNodes.end(); ++i) {
		if(RaySphereCollision(ret->cr,*((CollisionSphere*)(*i)->GetPhysicsNode().getCV()))) {
			//cout<<"true"<<endl;
			ret->SetRandomColour();
			if(!on && lastclick){
			cout<<"hit"<<endl;
				if(force>2500.0f)
					(*i)->hit(true);
				else
					(*i)->hit(false);
				break;
			}
			//cout << "true!" << endl;
		}
	}

	for(vector<EnemyEntity*>::iterator i = enemyNodes.begin(); i != enemyNodes.end(); ++i) {
		if((*i)->doShoot()) {
			EnemyFire(*i);
		}
		
	}

	if(!on) force = 0.0f;

	lastclick = on;

	float dt = msec * 0.01f;
	/*
	for(vector<PhysicsNode*>::iterator i = allNodes.begin(); i != allNodes.end(); ++i) {
		(*i)->Update(msec);
	}
	
	for(vector<LaserEntity*>::iterator i = laserNodes.begin(); i != laserNodes.end(); ++i) {
		(*i)->Update(msec);
	}
	*/
}
void	PhysicsSystem::Update(float msec) 
{
	listLock.lock();
	BroadPhaseCollisions();
	NarrowPhaseCollisions();

	for(vector<PhysicsNode*>::iterator i = allNodes.begin(); i != allNodes.end(); ++i) 
	{
		(*i)->Update(msec);
	}
	listLock.unlock();
}