Example #1
0
void TGame::updateBullets() {
	char cObjectHit;
	hit hObj;
		
	vector<bullet>::iterator iBullet;
	vector<vector<bullet>::iterator> vRemoveList;
	vector<vector<bullet>::iterator>::iterator vRemoveListIt;
	for (iBullet = vBullets.begin(); iBullet != vBullets.end(); iBullet++) {
		iBullet->update();
		//Do Hit Test and if a Hit - insert a hit into the hit vector
		
 		cObjectHit = doHitTest(iBullet->location.x, iBullet->location.y);
		if (cObjectHit != 'n') {
			hObj = hit();
			hObj.cObjectHit = cObjectHit;
			hObj.pLocation.x = iBullet->location.x;
			hObj.pLocation.y = iBullet->location.y;
			vHits.push_back(hObj);
			vRemoveList.push_back(iBullet);
		}
		//x = iBullet->location.x/50;
		//y = iBullet->location.y/50;
		//if (x > 1) x = 1;
		//if (x < -1) x = -1;
		//if (y > 1) y = 1;
		//if (y < -1) y = -1;
	}
	
	//delete bullets that have destroyed something
	for (vRemoveListIt = vRemoveList.begin(); vRemoveListIt != vRemoveList.end(); vRemoveListIt++) {
		vBullets.erase(*vRemoveListIt);
	}
	vRemoveList.clear();
}
Example #2
0
void Controller::OnMouseDown(Flags nFlags, int x, int y)
{
	down = mouse = Point(x,y);

	Ptr<SceneNode> pSelected = doHitTest( getViewport().DPtoRay(x, y), *getViewport().getScene(), NULL );

	if(pSelected)
	{
		if(pSelected->Flags() & SceneNode::FLAG_SELECTED)
			pSelected->Flags() &= ~SceneNode::FLAG_SELECTED;
		else
			pSelected->Flags() |= SceneNode::FLAG_SELECTED;
	}
}