src/bullets.cpp
// moveBulletUnit *****
// This method moves an individual bullet unit.

moveBulletUnit
This method moves an individual bullet unit.
moveBulletUnit This method moves an individual bullet unit .
bool moveBulletUnit(
	DWORD frameNumber,
	vectorListNodeStruct<bulletUnitStruct>& unit)
{
	genericUnitTypeDataStruct* myType=&(bulletType[unit.data.unitType]);
	frameDataStruct* myUnitFrame=&(myType->frames[unit.data.currentFrame]);
	bool wasGoingToPoint=unit.data.goingToPoint;
	if (!autoFrameUnit(&(unit.data))) return false;
	switch(unit.data.currentFrame) {
	case -1:
		if (!freeSlavesOf(&unit.data)) return false;
		if (!bulletList.removeNode(bulletList.getIndex(&unit)))
			return false;
		return true;
	default:
		break;
	}
	myUnitFrame=getUnitFrame(&unit.data);
	if (unit.data.slaveOf.objectType!=FILE_GAMEDATA_GAMEOBJECT_EMPTY)
		return true;
	if (unit.data.isPosRelative) {
		unit.data.x=gameWorld.xCamera+unit.data.xFromCamera;
		unit.data.y=gameWorld.yCamera+unit.data.yFromCamera;
	}
	if (unit.data.goingToPoint) {
		if (!unintelligentLinealMove(&unit.data))
			return false;
	}else{
		switch (unit.data.unitType) {
		case FILE_GAMEDATA_BULLET_PLAYERFLAME:
			unit.data.x+=unit.data.speedX;
			unit.data.y+=unit.data.speedY;
			break;
		}
	}
	if (wasGoingToPoint && !unit.data.goingToPoint) {
		gameObjectPointerStruct objPointer;
		objPointer.id=FILE_GAMEDATA_SOMEWALL_ID;
		objPointer.listIndex=0;
		objPointer.objectType=FILE_GAMEDATA_GAMEOBJECT_VIRTUALWALL;
		bulletUnitHit(unit, objPointer);
	}
	myUnitFrame=getUnitFrame(&unit.data);
	if (unit.data.isPosRelative) {
		unit.data.xFromCamera=unit.data.x-gameWorld.xCamera;
		unit.data.yFromCamera=unit.data.y-gameWorld.yCamera;
	}
	if (!moveWithOwner(&unit.data)) return false;
	if (isUnitInsideTheScreen(&unit.data)) {
		unit.data.timeOutsideTheScreenLeft=0;
	}else{
		if (unit.data.timeOutsideTheScreenLeft<=0) {
			unit.data.timeOutsideTheScreenLeft=
				unit.data.timeOutsideTheScreenMax;
		}else{
			unit.data.timeOutsideTheScreenLeft--;
		}
		if (unit.data.timeOutsideTheScreenLeft<=0) {
			if (!freeSlavesOf(&unit.data)) return false;
			if (!bulletList.removeNode(bulletList.getIndex(&unit)))
				return false;
			return true;
		}
	}
	return true;
}
bool moveBulletUnit ( DWORD frameNumber , vectorListNodeStruct < bulletUnitStruct > & unit ) { genericUnitTypeDataStruct * myType = & ( bulletType [ unit . data . unitType ] ) ; frameDataStruct * myUnitFrame = & ( myType -> frames [ unit . data . currentFrame ] ) ; bool wasGoingToPoint = unit . data . goingToPoint ; if ( ! autoFrameUnit ( & ( unit . data ) ) ) return false ; switch ( unit . data . currentFrame ) { case -1 : if ( ! freeSlavesOf ( & unit . data ) ) return false ; if ( ! bulletList . removeNode ( bulletList . getIndex ( & unit ) ) ) return false ; return true ; default : break ; } myUnitFrame = getUnitFrame ( & unit . data ) ; if ( unit . data . slaveOf . objectType != FILE_GAMEDATA_GAMEOBJECT_EMPTY ) return true ; if ( unit . data . isPosRelative ) { unit . data . x = gameWorld . xCamera + unit . data . xFromCamera ; unit . data . y = gameWorld . yCamera + unit . data . yFromCamera ; } if ( unit . data . goingToPoint ) { if ( ! unintelligentLinealMove ( & unit . data ) ) return false ; } else { switch ( unit . data . unitType ) { case FILE_GAMEDATA_BULLET_PLAYERFLAME : unit . data . x += unit . data . speedX ; unit . data . y += unit . data . speedY ; break ; } } if ( wasGoingToPoint && ! unit . data . goingToPoint ) { gameObjectPointerStruct objPointer ; objPointer . id = FILE_GAMEDATA_SOMEWALL_ID ; objPointer . listIndex = 0 ; objPointer . objectType = FILE_GAMEDATA_GAMEOBJECT_VIRTUALWALL ; bulletUnitHit ( unit , objPointer ) ; } myUnitFrame = getUnitFrame ( & unit . data ) ; if ( unit . data . isPosRelative ) { unit . data . xFromCamera = unit . data . x - gameWorld . xCamera ; unit . data . yFromCamera = unit . data . y - gameWorld . yCamera ; } if ( ! moveWithOwner ( & unit . data ) ) return false ; if ( isUnitInsideTheScreen ( & unit . data ) ) { unit . data . timeOutsideTheScreenLeft = 0 ; } else { if ( unit . data . timeOutsideTheScreenLeft <= 0 ) { unit . data . timeOutsideTheScreenLeft = unit . data . timeOutsideTheScreenMax ; } else { unit . data . timeOutsideTheScreenLeft -- ; } if ( unit . data . timeOutsideTheScreenLeft <= 0 ) { if ( ! freeSlavesOf ( & unit . data ) ) return false ; if ( ! bulletList . removeNode ( bulletList . getIndex ( & unit ) ) ) return false ; return true ; } } return true ; }
moveBulletUnit 
This method moves an individual bullet unit.
moveBulletUnit This method moves an individual bullet unit .
// current frame
 // bullet unit to move
 // we use this to know if the unit was going to a given point
 // before executing the unintelligent lineal movement
 // AUTOFRAMING BEGIN
 // auto frame it
 // check for negative frame numbers (they use to have a meaning,
 // attached)
 // BULLET SPECIFIC CODE BEGIN
 // frame -1 means: this unit should stop existing!
 // free the slaves of this unit
 // remove the unit
 // the unit has been removed, we cannot continue here
 // BULLET SPECIFIC CODE END
 // no problem here...
 // AUTOFRAMING END
 // to avoid mistakes, update the frame info
 // if this unit is a slave of any other, no more work should be
 // done here
 // move the unit with the camera if it's necessary
 // should we move the unit to some specific point?
 // that is, unintelligent movement vs. intelligent movement
 // failed!
 // typical ai
 // move it
 // move always
 // check if it has just stopped going to a point
 // kill the bullet
 // it's not in any list
 // collided!
 // to avoid mistakes, update the frame info
 // update the *FromCamera variables if necessary
 // let's move the unit with the owner unit, if any
 // VISIBILITY CHECK BEGIN
 // Checks for visibility after the unit moved...
 // It's inside the screen, zero the counter
 // The unit is outside the screen.
 // That's the first time now, set to the max
 // It's not the first time, decrement the counter first
 // Now see if it hasn't been too much time out there
 // It's been too much time out there, remove it.
 // free the slaves of this unit
 // remove the unit
 // the unit has been removed, we cannot continue here
 // END VISIBILITY CHECK
 // all ok
