本文整理汇总了C++中ship::getY方法的典型用法代码示例。如果您正苦于以下问题:C++ ship::getY方法的具体用法?C++ ship::getY怎么用?C++ ship::getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship
的用法示例。
在下文中一共展示了ship::getY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseMovement
//***********************************************************************************
// 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
示例2: drawHUD
//***********************************************************************************
// 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;
}
示例3: checkIfAtPlanet
//***********************************************************************************
// 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);
//.........这里部分代码省略.........