示例#1
0
	void CameraFreeView (int iID, float move, float ystep, float xturn, float yturn)
	{
		if (!camera.ACTIVE) return;
		// Tastatur Steuerung
		if (dbUpKey()==1)			{	camera.UPDATE=true;	dbMoveCamera(    iID, move);		}
		if (dbDownKey()==1)		{	camera.UPDATE=true;	dbMoveCamera(    iID, -move);									}
		if (dbLeftKey()==1)		{	camera.UPDATE=true;	dbYRotateCamera( iID, dbWrapValue(camera.b-yturn));	}
		if (dbRightKey()==1)		{	camera.UPDATE=true;	dbYRotateCamera( iID, dbWrapValue(camera.b+yturn));	}
		if (dbScanCode()==201)  {	camera.UPDATE=true;	dbXRotateCamera( iID, dbWrapValue(camera.a+xturn));	}
		if (dbScanCode()==209) 	{	camera.UPDATE=true;	dbXRotateCamera( iID, dbWrapValue(camera.a-xturn));	}
		if (dbShiftKey()==1) 	{	camera.UPDATE=true;	dbPositionCamera(iID, camera.x,camera.y+ystep,camera.z);}
		if (dbControlKey()==1) 	{	camera.UPDATE=true;	dbPositionCamera(iID, camera.x,camera.y-ystep,camera.z);}

		// Maus Steuerung
		if ( mouse.c == 2)
		{

		if ( mouse.mx != 0.0f)	{	camera.UPDATE=true;	dbYRotateCamera(iID,dbCurveAngle(dbWrapValue(camera.b+mouse.mx),camera.b,2.5f));	}
		if ( mouse.my != 0.0f)	{	camera.UPDATE=true;	dbXRotateCamera(iID,dbCurveAngle(dbWrapValue(camera.a+mouse.my),camera.a,2.5f));	}
		if ( mouse.mz != 0.0f)	{	camera.UPDATE=true;	dbMoveCamera(iID,mouse.mz);}
		}
	}
示例#2
0
void movePersonOrWorld(int &xCord, int &yCord, int &direction) { //This function checks to see which direction you are planning for your character or world to move in, according to your arrow keys. It then checks to see if there are any collisions, or space bar events, and if not, it updates your new position. 
	if(dbUpKey()==1)
		{
			direction = 1;
			if(dbSpriteFrame(1) < 13) //If our frame for the character is not within its proper regions (In this case, is on a frame that's below our up animation):
			{
				dbSetSpriteFrame(1,13); //Set the first sprite frame to 13, so we can play through the upwards animation correctly.
			}

			if(dbShiftKey() == 1)
			{
				dbPlaySprite(1, 13, 16, 75); //play through our animations (from 13 to 16) with a 75 millisecond delay since we're running.
				if(house.checkSpriteCollision(xCord,yCord-3) == 0) 
				{
					yCord -= 3;
				}
			}
			else
			{
				dbPlaySprite(1, 13, 16, 150); //play through our animations (from 13 to 16) with a 150 millisecond delay because we're walking.
				if(house.checkSpriteCollision(xCord,yCord-1) == 0) 
				{
					yCord --;
				}
			}
		}
		else if(dbDownKey()==1)
		{
			direction = 2; //we set our direction variable to 2, which represents the downward motion.
			if(dbSpriteFrame(1) > 4) //Like before, if our sprite 1 frame is out of its desired regions, then set it to the correct location.
			{
				dbSetSpriteFrame(1, 4);
			}

			if(dbShiftKey() == 1)
			{
				dbPlaySprite(1, 1, 4, 75);
				if(house.checkSpriteCollision(xCord,yCord+3) == 0) 
				{
					yCord += 3;
				}
			}
			else
			{
				dbPlaySprite(1, 1, 4, 150);
				if(house.checkSpriteCollision(xCord,yCord+1) == 0) 
				{
					yCord ++;
				}
			}
		}
		else if(dbLeftKey()==1)
		{
			direction = 3; //Set our variable to 3 which represents leftward motion.
			if(dbSpriteFrame(1) < 5 || dbSpriteFrame(1) > 8)
			{
				dbSetSpriteFrame(1,5);
			}
			if(dbShiftKey() == 1)
			{
				dbPlaySprite(1, 5, 8, 75);
				if(house.checkSpriteCollision(xCord-3,yCord) == 0) 
				{
					xCord -= 3;
				}
			}
			else
			{
				dbPlaySprite(1, 5, 8, 150);
				if(house.checkSpriteCollision(xCord-1,yCord) == 0) 
				{
					xCord --;
				}
			}
		}
		else if(dbRightKey()==1)
		{
			direction = 4; //Set our variable to 4 which represents rightward motion.
			if(dbSpriteFrame(1) < 9 || dbSpriteFrame(1) > 12)
			{
				dbSetSpriteFrame(1,9);
			}
			if(dbShiftKey() == 1)
			{
				dbPlaySprite(1, 9, 12, 75);
				if(house.checkSpriteCollision(xCord+3,yCord) == 0) 
				{
					xCord += 3;
				}
			}
			else
			{
				dbPlaySprite(1, 9, 12, 150);
				if(house.checkSpriteCollision(xCord+1,yCord) == 0) 
				{
					xCord ++;
				}
			}
		}
		if(dbKeyState(57) == 1){ //If we pressed the space bar, check to see if we have an event associated with that object.
			house.getEvent(direction,xCord,yCord);
		}
	house.updateWorld(xCord,yCord); //Now let's update the world with our new information.
}
示例#3
0
	void CameraCylinder (int iID,float move, float ystep, float yturn)
	{
		if (!camera.ACTIVE) return;

		//Left
		if (dbLeftKey()==1)		
		{	
			camera.b=dbWrapValue(camera.b+yturn);
			float distXZ=dbSQRT(camera.x*camera.x+camera.z*camera.z);
			camera.x=dbNewXValue(camera.point.x,camera.b,-distXZ);
			camera.z=dbNewZValue(camera.point.z,camera.b,-distXZ);
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.UPDATE=true;
		}
		//Right
		if (dbRightKey()==1)		
		{
			camera.b=dbWrapValue(camera.b-yturn);	
			float distXZ=dbSQRT(camera.x*camera.x+camera.z*camera.z);
			camera.x=dbNewXValue(camera.point.x,camera.b,-distXZ);
			camera.z=dbNewZValue(camera.point.z,camera.b,-distXZ);
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.UPDATE=true;
		}
		//Shift
		if (dbShiftKey()==1)		
		{	
			camera.y += ystep;
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.a=dbCameraAngleX(iID);
			camera.UPDATE=true;
		}
		//Strg
		if (dbControlKey()==1)	
		{	
			if (camera.y>=ystep)
			{
			camera.y -= ystep;
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.a=dbCameraAngleX(iID);
			camera.UPDATE=true;
			}
		}
		//Up
		if (dbUpKey()==1)	
		{	
			dbMoveCamera(iID,move);
			camera.x=dbCameraPositionX(iID);
			camera.y=dbCameraPositionY(iID);
			camera.z=dbCameraPositionZ(iID);
			camera.UPDATE=true;
		}
		//Down
		if (dbDownKey()==1)
		{	
			dbMoveCamera(iID,-move);
			camera.x=dbCameraPositionX(iID);
			camera.y=dbCameraPositionY(iID);
			camera.z=dbCameraPositionZ(iID);
			camera.UPDATE=true;
		}
		//Mouse
		if (mouse.c==2)
		{
		if ( mouse.mx != 0.0f)	{	dbYRotateCamera(iID,dbCurveAngle(dbWrapValue(dbCameraAngleY(iID)+mouse.mx),dbCameraAngleY(iID),2.5f));	}
		if ( mouse.my != 0.0f)	{	dbXRotateCamera(iID,dbCurveAngle(dbWrapValue(dbCameraAngleX(iID)+mouse.my),dbCameraAngleX(iID),2.5f));	}
		if ( mouse.mz != 0.0f)	{	dbMoveCamera(iID,mouse.mz);}
		}	
	}