Esempio n. 1
0
//***********************************************************************************
// int parseStringX()  
// This is a simple function to parse and return the coodinates you want to goto
// 
// 
//**********************************************************************************
void parseMovement(string strX,string strY,ship &s)
{
   int x;
   int y;
   double hypot=0.0;

    

 
   x = atoi(strX.c_str());
   y = atoi(strY.c_str());
  

   if (x == 0)
   {
	s.setX(s.getX());
   }
  
   if (y == 0)
   {
	s.setY(s.getY());
   }


   if (x <= POSITIVE_XLIMIT && x >= NEGATIVE_XLIMIT && y <= POSITIVE_YLIMIT && y >= NEGATIVE_YLIMIT)
  {
  // calculate data for hypotenuese (sp?) and get units for fuel subtraction
   double xc = x-s.getX();
   double yc = y-s.getY();
  
   double xcsq = xc*xc;
   double yxsq = yc*yc;

   double hypot = abs(sqrt(xcsq+yxsq));
	  // error checking for input
	outfile.open("errorLog.txt", ios::app);
	outfile  << "The time is: " << asctime(localtm) << " " << "Hypotenoose: " << hypot << endl;
    outfile.close();
     // ------
	  s.setX(x);  // 
	  s.setY(y);
  
	  s.setFuel(s.getFuel()-hypot);
  }

 

} // end of method
Esempio n. 2
0
//***********************************************************************************
// void drawHUD()  
// This is a simple function to draw out the text description of where you are
// 
// 
//**********************************************************************************
int drawHUD(int mx, int my, ship &s)
{
 
  string asciiPos;	 
  string stringX;
  string stringY;
  int eight=8;
  int input=0;

   cout << "The Moon (m), your home base is located at: "; 
   //SetConsoleTextAttribute(hOut, FOREGROUND_GREEN);
   cout << mx << ", " << my << " - You are located at: " << s.getX() << ", " << s.getY();
   //SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
   cout << "\nStatus - Fuel: " << s.getFuel() << " Spacebucks: " << s.getFunds() << endl;
   cout << "Cargo Hold: Rice: " << s.getRice() << " IRON: " << s.getIron() << " SUGAR: " << s.getSugar() << endl;
   //cout << "What do you want to do? (1 +x 2 -x 3 +y 4 -y -- 8 is quit) ";
   cout << "Where do you want to move? (XX,YY -- 8 is quit) ";
   cin >> asciiPos;
   
// error cehcking for input

   	outfile.open("inputLog.txt", ios::app);
	outfile  << "The time is: " << asctime(localtm) << " " << "asciiPos: " << asciiPos << endl;
    outfile.close();
//  ---------------

   if (asciiPos == "8"){
       exit(0);
   }
   stringX=asciiPos.substr(0,2);
   stringY=asciiPos.substr(3,5);

   parseMovement(stringX,stringY,s);
   //parseStringY(stringY,s.getY());

   if (atoi(asciiPos.c_str()) == eight)
   {
   input=8;
   }
   else
   {
	   // Input is coming in a format of XX,YY a five char string
	   // it is beingsplit assuming that the input is two chars comma and two more
	   //  each value is being assigned to the x,y value - which is strange because I think
	   //  the x,y value is opposite anyway. =P
	
  // s.setX(atoi(stringX.c_str()));  // must cast the string into an integer so that you can repostion your ship
   //s.setY(atoi(stringY.c_str()));  // ditto	
   }
   return input;
}
Esempio n. 3
0
//***********************************************************************************
// void checkIfAtPlanet()  
// This fucntion checks to see if you have arrived at a planet, then it'd put you
// in the store.
// 
//**********************************************************************************
void checkIfAtPlanet(ship &s,planet &jupiter,planet &earth,planet &mars,planet &ganymede,planet &moon,planet &saturn,planet &neptune,planet &pluto,planet &ceres)
{
   short input = 0;
//**********************************************************************************
// 1. Jupiter
//**********************************************************************************
	if (s.getX()==jupiter.getX() && s.getY()==jupiter.getY())
    {
	   jupiter.Shop(s);
	
	  
	}
      // end of jupiter if
//**********************************************************************************
// 2. Earth
//**********************************************************************************
      if (s.getX()==earth.getX() && s.getY()==earth.getY())
   {
	   earth.Shop(s);
	
	 
	}
// end of earth if	   
//**********************************************************************************
// 3. Mars
//**********************************************************************************
      if (s.getX()==mars.getX() && s.getY()==mars.getY())
   {
	   mars.Shop(s);
	
	  
	}
// end of mars if
//**********************************************************************************
// 4. Ganymede
//**********************************************************************************
   if (s.getX()==ganymede.getX() && s.getY()==ganymede.getY())
   {
	   
	  ganymede.Shop(s);
	  
 
    }
//**********************************************************************************
// 5. Saturn
//**********************************************************************************
   if (s.getX()==saturn.getX() && s.getY()==saturn.getY())
   {

       saturn.Shop(s);
	 
 
    }
//**********************************************************************************
// 6. Pluto
//**********************************************************************************
	     if (s.getX()==pluto.getX() && s.getY()==pluto.getY())
   {
	
	   pluto.Shop(s);
	 
 
    }
//**********************************************************************************
// 7. Ceres
//**********************************************************************************
		 
		 if (s.getX()==ceres.getX() && s.getY()==ceres.getY())
   {
	 ceres.Shop(s);
	
 
    }
//**********************************************************************************
// 8. Neptune
//**********************************************************************************
		 
		 if (s.getX()==neptune.getX() && s.getY()==neptune.getY())
   {
        neptune.Shop(s);	  
	 
 
    }
//**********************************************************************************
// 9. Moon -- different from planet
//**********************************************************************************
  if (s.getX()==moon.getX() && s.getY()==moon.getY())
   {
	   
	  do 	
	  { // begin do loop
	   
	   input = checkIfAtMoonMenu(s,jupiter,earth,mars,ganymede,moon,saturn,neptune,pluto,ceres);	  
         
	   cout << "1. Check Mail Box: -- Not Functional... " << endl;
	   cout << "2. Repair Ship: -- Not Functional... " << endl;
	   cout << "3. Upgrade Ship: -- Not Functional... " << endl;
	   cout << "4. Pick Up Passengers: -- Not Functional... " << endl;
	   cout << "5. Talk to people listen to space news... -- not functional... " << endl;


       switch(input)
	   {
	   case 1: 
		   system("cls");
           //checkMailBox();   
		   cout << "N/A" << endl;
		   break;
	   case 2:
     	   system("cls");
           //repairShip();
		   cout << "N/A" << endl;
		   break;
	   case 3:
     	   system("cls");
		   //upgradeShip();
           cout << "N/A" << endl;
		   break;
	   case 4:
     	   system("cls");
		   //pickUpPassengers();
           cout << "N/A" << endl;
		   break;
	   case 5:
     	   system("cls");
		   //talkToPeople();
           cout << "N/A" << endl;
		   break;
		case 6:
     	   system("cls");
           cout << "Take Care out there in space..." << endl;
		   break;

	   default:
		     cout << "You can only choose option 1-5 are not programmed, nothing else is programmed... " << endl;
		     break;
	   }// end of switch
       		  
	  } // end of do
	   while (input == 1 || input == 2 || input == 3  || input == 4 || input == 5);
	   s.setX(s.getX()+1);
	   s.setY(s.getY()+1);
 
    }

  s.setX(s.getX()+1);
} // end of method