Example #1
0
void wallFollower(Maze *maze, Mouse *mouse) {
    int cNorth;
    int cEast;
    int cSouth;
    int cWest;
    int wallFront;
    int wallRight;
    int wallLeft;
    // See what walls are in the cell
    cNorth=maze->actualMap[mouse->row][mouse->col].north;
    cEast=maze->actualMap[mouse->row][mouse->col].east;
    cSouth=maze->actualMap[mouse->row][mouse->col].south;
    cWest=maze->actualMap[mouse->row][mouse->col].west;

    if(mouse->ori==0) {
        wallFront=cNorth;
        wallRight=cEast;
        wallLeft=cWest;
    }
    else if(mouse->ori==1) {
        wallFront=cEast;
        wallRight=cSouth;
        wallLeft=cNorth;
    }
    else if(mouse->ori==2) {
        wallFront=cSouth;
        wallRight=cWest;
        wallLeft=cEast;
    }
    else {
        wallFront=cWest;
        wallRight=cNorth;
        wallLeft=cSouth;
    }

    // Decide where to turn
    if(!wallRight) {
        faceRight(mouse);
 //       printf("Mouse turned right\n");
    } 
    else if(!wallFront) {
        // Do Nothing
//        printf("Mouse did nothing\n");
    }
    else if(!wallLeft) {
        faceLeft(mouse);
 //       printf("Mouse turned left\n");
    }
    else {
        faceBack(mouse);
  //      printf("Moused turned around\n");
    }
    moveForward(mouse);
   //     printf("Mouse moved %d\n",mouse->ori);
}
Example #2
0
std::vector<Plane> Frustum::FormPlane()
{
	std::vector<Plane> vPlane;
	vPlane.resize(6);
   
	point   fnOri  = m_NLUp;
	point   fndir1 = m_NLBp - m_NLUp;
	point   fndir2 = m_NRUp - m_NLUp;
	Plane	faceNear(fnOri,fndir1,fndir2);//除加儒中

	point   ffOri  = m_FRBp;
	point   ffdir1 = m_FRBp - m_FRUp;
	point   ffdir2 = m_FLUp - m_FRUp;
	Plane	faceFar(ffOri,ffdir1,ffdir2);//垓加儒中

	point   frOri  = m_NRUp;
	point   frdir1 = m_NRBp - m_NRUp;
	point   frdir2 = m_FRUp - m_NRUp;
	Plane	faceRight(frOri,frdir1,frdir2);//嘔中

	point   flOri  = m_FLUp;
	point   fldir1 = m_FLBp - m_FLUp;
	point   fldir2 = m_NLUp - m_FLUp;
	Plane	faceLeft(flOri,fldir1,fldir2);//恣中

	point   fuOri  = m_FRUp;
	point   fudir1 = m_FLBp - m_FRUp;
	point   fudir2 = m_NRUp - m_FRUp;
	Plane	faceUP(fuOri,fudir1,fudir2);//貧中

	point   fbOri  = m_NRBp;
	point   fbdir1 = m_NLBp - m_NRBp;
	point   fbdir2 = m_FRBp - m_NRBp;
	Plane	faceButtom(fbOri,fbdir1,fbdir2);//和中
	
	vPlane[0] = faceNear;
	vPlane[1] = faceFar;
	vPlane[2] = faceLeft;
	vPlane[3] = faceRight;
	vPlane[4] = faceUP;
	vPlane[5] = faceButtom;
	return vPlane;
}
Example #3
0
void faceBack(Mouse *mouse) {
    faceLeft(mouse);
    faceLeft(mouse);
}