本文整理汇总了C++中Entity::GetPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetPositionX方法的具体用法?C++ Entity::GetPositionX怎么用?C++ Entity::GetPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::GetPositionX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sqrt
bool
Entity::IsCollidingWith(Entity& e)
{
// Ex006.4: Generic Entity Collision routine.
// Ex006.4: Does this object collide with the e object?
// Ex006.4: Create a circle for each entity (this and e).
// Ex006.4: Check for intersection.
// Ex006.4: Using circle-vs-circle collision detection.
// Ex006.4: Return result of collision.
int x1 = e.GetPositionX() + 8;
int y1 = e.GetPositionY() + 8;
int radius1 = 16;
int radius2 = 16;
//compare the distance to combined radii
if (sqrt((x1 - m_x) * (x1 - m_x) + (y1 - m_y) * (y1 - m_y)) < 32)
{
return true;
//Console.WriteLine("The 2 circles are colliding!");
}
//if (sqrt(pow((x1 - m_x), 2) + pow((y1 - m_y), 2) < 32))
//sqrt((x2 – x1) ^ 2 + (y2 – y1) ^ 2) – r1 – r2
float t = sqrt(pow((x1 - m_x), 2) + pow((y1 - m_x), 2) - 1 - 1);
if (t <= 0) {
//return true;
}
return (false); // Ex006.4 Change return value!
}
示例2: if
bool
Wall::IsCollidingWith(Entity& e, bool lockdown)
{
bool result = false;
int eWidth = e.getWidth();
int eHeight = e.getHeight() / 2;
int entityX = e.GetPositionX();
int entityY = e.GetPositionY() + eHeight;
if (wa_xloc + wa_width <= entityX || wa_xloc >= entityX + eWidth){
return false;
}
if (wa_yloc + wa_height <= entityY || wa_yloc >= entityY + eHeight){
return false;
}
if (wa_side == TOP ){
if (wa_door && wa_open && !lockdown){
e.SetPositionX(wa_xloc + 10);
}
else{
if (wa_yloc + (wa_height - 50) <= entityY && wa_yloc + wa_height >= entityY){ //done
//south, blocks moving up
e.SetPositionY(wa_yloc + 41);
result = true;
}
else if (wa_xloc <= entityX + eWidth && wa_xloc + 50 >= entityX + eWidth){ //done
//west, blocks moveing right
e.SetPositionX(wa_xloc - (eWidth + 1));
result = true;
}
else if (wa_xloc + (wa_width - 50) <= entityX && wa_xloc + wa_width >= entityX){ //done
//east, blocks moving left
e.SetPositionX(wa_xloc + 151);
result = true;
}
}
}
else if (wa_side == BOTTOM){
if (wa_door && wa_open && !lockdown){
e.SetPositionX(wa_xloc + 10);
}
else{
if (wa_yloc <= entityY + eHeight && wa_yloc + 50 >= entityY + eHeight){
//north, blocks moving down
e.SetPositionY(wa_yloc - ((eHeight * 2) + 1));
result = true;
}
else if (wa_xloc <= entityX + eWidth && wa_xloc + 50 >= entityX + eWidth){ //done
//west, blocks moveing right
e.SetPositionX(wa_xloc - (eWidth + 1));
result = true;
}
else if (wa_xloc + (wa_width - 50) <= entityX && wa_xloc + wa_width >= entityX){ //done
//east, blocks moving left
e.SetPositionX(wa_xloc + 151);
result = true;
}
}
}
else if (wa_side == LEFT){
if (wa_door && wa_open && !lockdown){
e.SetPositionY(wa_yloc - 10);
//result = true;
}
else{
if (wa_xloc + (wa_width - 50) <= entityX && wa_xloc + wa_width >= entityX){ //done
//east, blocks moving left
e.SetPositionX(wa_xloc + 151);
result = true;
}
else if (wa_yloc <= entityY + eHeight && wa_yloc + 50 >= entityY + eHeight){
//north, blocks moving down
e.SetPositionY(wa_yloc - ((eHeight * 2) + 1));
result = true;
}
else if (wa_yloc + (wa_height - 50) <= entityY && wa_yloc + wa_height >= entityY){ //done
//south, blocks moving up
e.SetPositionY(wa_yloc + 41);
result = true;
}
}
}
else if (wa_side == RIGHT){
//.........这里部分代码省略.........