本文整理汇总了C++中Coords::getY方法的典型用法代码示例。如果您正苦于以下问题:C++ Coords::getY方法的具体用法?C++ Coords::getY怎么用?C++ Coords::getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coords
的用法示例。
在下文中一共展示了Coords::getY方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coordsToIndex
size_t Board::coordsToIndex(const Coords &c) const {
if (!inRange(c)) {
throw std::out_of_range("Passed coords are outside of board range.");
}
return dim.getX() * c.getX() + c.getY();
}
示例2:
bool Coords::operator==(const Coords& c) const {
double tol = 0.05;
if (std::abs(c.getX() - this->getX()) < tol and std::abs(c.getY() - this->getY()) < tol) {
return true;
}
return false;
}
示例3: getArea
virtual double getArea() {
return fabs((c2.getX()-c1.getX())*(c2.getY()-c1.getY()));
}
示例4: mapGen
void mapGen(int** checkWall, int** checkVisited, int X, int Y)
{
int x = 0, y = 1, tolerance = 0; //x and y are the starting coordinates of the path through the maze
int sum = 0;
Coords temp;
temp.setCoords(1, 0);
stack<Coords> coordinates;
coordinates.push(temp);
while (!coordinates.empty()) { //continues the loop until the stack is emptied
//////////////////////////////////////////////////
cout << "size of stack: " << coordinates.size() << endl;
mapgen << "size of stack: " << coordinates.size() << endl;
/////////////////////////////////////////////////
int* possible = checkAvail(coordinates.top(), checkVisited, X, Y, tolerance); //ptr to the array of size 4 that contains the four directions' validity
sum = 0;
for (int i = 0; i < 4; i++)
{
sum += possible[i]; //sets sum to the total number of choices
}
////////////////////////////////////
Coords test = coordinates.top();
int testX = test.getX();
int testY = test.getY();
mapgen << "options: " << sum << " coords: " << testX << " " << testY << endl;
///////////////////////////////////////
if (sum == 0) { //executes if there are no choices at the current location (dead end)
coordinates.pop(); //pops the top layer off the stack
tolerance = 1; //allows checkAvail to evaluate to true even if the location has been visited once before (allows the making of intersections
/////////////////////////////////////////
mapgen << "pop" << endl;
/////////////////////////////////////////
continue; //back up to beginning of the while loop
}
tolerance = 0; //for checkAvail on the next run through the loop
temp = coordinates.top(); //local variables for the x- and y-coordinates of the current location
x = temp.getX();
y = temp.getY();
int Picked = pickDir(possible);
//////////////////////////
mapgen << "direction:" << Picked << endl;
/////////////////////////
if (x > 0) //updates checkVisited now that we've moved
checkVisited[x - 1][y] ++; //
if (x < X - 2) //
checkVisited[x + 1][y] ++; //
if (y > 0) //
checkVisited[x][y - 1] ++; //
if (y < Y - 2) //
checkVisited[x][y + 1] ++; //
switch (Picked) //moves us to the next location
{ //
case 0: { //up //
y--; //
break; //
} //
case 1: { //left //
x--; //
break; //
} //
case 2: { //down //
y++; //
break; //
} //
case 3: { //right //
x++; //
break; //
} //
}
temp.setCoords(x, y); //puts the new location into a Coords object
coordinates.push(temp); //adds the new location to the stack
checkWall[x][y] = 0; //makes the new location a space
checkVisited[x][y] += 2;//sets it to "double visited," so it can never be visited again
}
}
示例5: inRange
bool Board::inRange(const Coords &c) const {
return c.getX() < dim.getX() && c.getY() < dim.getY();
}
示例6: or
bool Coords::operator<(const Coords& c) const {
return this->getX() < c.getX() or(this->getX() == c.getX() and this->getY() < c.getY());
}