本文整理汇总了C++中BBox::getLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::getLeft方法的具体用法?C++ BBox::getLeft怎么用?C++ BBox::getLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBox
的用法示例。
在下文中一共展示了BBox::getLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Enemy::update()
{
if (this->position[0] >= windowBox.getRight())
this->position[0] = position[0] - (windowBox.getRight() - windowBox.getLeft());
this->boundBox->minX = this->position[0] + this->minX;
this->boundBox->maxX = this->position[0] + this->maxX;
this->boundBox->minY = this->position[1] + this->minY;
this->boundBox->maxY = this->position[1] + this->maxY;
}
示例2: checkCollision
//circle(zombie) to rectangle collision detection
bool Zombie::checkCollision(std::vector<BBox>* boxes, float p_x, float p_y){
BBox box;
Point A = Point(this->getX(), this->getY());
Point B;
for(int i = 0; i<boxes->size();i++){
box = boxes->at(i);
//finds a point on the rectangles bounding box and that point acts as a circle with a radius 0 radius
if(box.getRight() < this->getBox().getLeft())
B.setX(box.getRight());
else if(box.getLeft() > this->getBox().getRight())
B.setX(box.getLeft());
else
B.setX(this->getX());
if(box.getTop() < this->getBox().getBottom())
B.setY(box.getTop());
else if(box.getBottom() > this->getBox().getTop())
B.setY(box.getBottom());
else
B.setY(this->getY());
float difx = (B.getX() - A.getX()) * (B.getX() - A.getX());
float dify = (B.getY() - A.getY()) * (B.getY() - A.getY());
float dist = difx + dify;
if(dist <= this->getRadius() * this->getRadius()){
//FOLLOWS THE EDGES OF BOX TO REACH the player
//if zombie is on below or above the box
if((this->getBox().getBottom() > box.getTop() ||
this->getBox().getTop() < box.getBottom())
){
//IF ON TOP
if(this->getBox().getBottom() > box.getTop()){
if(p_x == this->getX()){
this->angle = 0;
}
//if player is on the right of the zombie
else if(p_x > this->getX()){
//if the player is positioned higher than the zombie
if(this->getY() < p_y)
this->angle = 8;
else
this->angle = 0;
//if player is on the left of the zombie
}else {
//if the player is positioned higher than the zombie
if(this->getY() < p_y)
this->angle = 172;
else
this->angle = 180;
}
//IF BELOW THE BOX
}else if(this->getBox().getTop() < box.getBottom()){
if(p_x == this->getX()){
this->angle = 0;
}
//if player is on the right of the zombie
else if(p_x > this->getX()){
if(this->getY() > p_y)
this->angle = 352;
else
this->angle = 0;
//if player is on the left of the zombie
}else{
if(this->getY() > p_y)
this->angle = 188;
else
this->angle = 180;
}
}
//if zombie is on left or right side of the box
}else if((this->getBox().getRight() < box.getLeft() || this->getBox().getLeft() > box.getRight())
){
float up = box.getTop() - this->getY();
float down = this->getY() - box.getBottom();
//IF ON LEFT SIDE
if(this->getBox().getRight() < box.getLeft()){
if(p_y == this->getY() ){
this->angle = 90;
}
else if(p_y > this->getY()){
if(this->getX() > p_x)
this->turn(this->getX() - 16,box.getTop() +32);
else
this->turn(this->getX(),box.getTop() +32);
}
else{
if(this->getX() > p_x)
this->turn(this->getX() - 16,box.getBottom() -32);
else
this->turn(this->getX(),box.getBottom() - 32);
}
}
//.........这里部分代码省略.........