当前位置: 首页>>代码示例>>C++>>正文


C++ Stairs类代码示例

本文整理汇总了C++中Stairs的典型用法代码示例。如果您正苦于以下问题:C++ Stairs类的具体用法?C++ Stairs怎么用?C++ Stairs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Stairs类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: KawigiEdit_RunTest

// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, int p0, int p1, int p2, int p3, bool hasAnswer, int p4) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << p2 << "," << p3;
	cout << "]" << endl;
	Stairs *obj;
	int answer;
	obj = new Stairs();
	clock_t startTime = clock();
	answer = obj->designs(p0, p1, p2, p3);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p4 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p4;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
开发者ID:Ziklon,项目名称:algorithms,代码行数:37,代码来源:Stairs.cpp

示例2: getFloor

  void Maze::scanForEntrances() {
    for (uint32_t i = 1; i <= getFloorCount(); i++) {
      Map* curMap = getFloor(i);
      
      if (i == 1) {
        //  In this case, we want up stairs.
        bool foundEntrance = false;
        bool multipleWarned = false;
        for (int32_t y = 0; y < curMap->getHeight(); y++) {
          for (int32_t x = 0; x < curMap->getWidth(); x++) {
            Activatable* act = curMap->getActivatable(x, y);
            if (act) {
              Stairs* stairs = act->asStairs();
              if (stairs && stairs->getDirection() == StairDirection::UP) {
                Facing dstFacing = stairs->getDestinationFacing();
                
                //  Adjust the position so that when the player enters, they're
                //  facing the right direction, and in the right position.
                int32_t dstX = x;
                int32_t dstY = y;
                switch(dstFacing) {
                case Facing::NORTH:
                  dstY--;
                  break;
                case Facing::EAST:
                  dstX++;
                  break;
                case Facing::SOUTH:
                  dstY++;
                  break;
                case Facing::WEST:
                  dstX--;
                  break;
                }

                if (foundEntrance && !multipleWarned) {
                  writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances():  Multiple up stairs found on floor of maze.");
                  multipleWarned = true;
                }
                else {
                  if (!curMap->canEntityEnter(dstX, dstY)) {
                    writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances():  Entrance as specified would place player in solid wall.");
                  }
                  else {
                    mazeEntrance = Entrance(i, dstX, dstY, dstFacing);
                    foundEntrance = true;
                  }
                }
              }
            }
          }
        }
      }
      else {
        //  Otherwise, we're looking for geomagnetic poles.  This is currently
        //  not implemented.  Mostly because geopoles don't exist.
      }
    }
  }
开发者ID:CepheidVar,项目名称:ProjectIO,代码行数:59,代码来源:Maze.cpp

示例3: notify_collision_with_stairs

/**
 * \brief This function is called when some stairs detect a collision with this entity.
 * \param stairs the stairs entity
 * \param collision_mode the collision mode that detected the event
 */
void CarriedItem::notify_collision_with_stairs(Stairs& stairs, CollisionMode /* collision_mode */) {

  if (is_throwing
      && !is_breaking
      && stairs.is_inside_floor()
      && get_layer() == stairs.get_layer()) {
    break_one_layer_above = true; // show the destruction animation above the stairs
  }
}
开发者ID:Codex-NG,项目名称:solarus,代码行数:14,代码来源:CarriedItem.cpp

示例4: notify_collision_with_stairs

/**
 * @brief This function is called when some stairs detect a collision with this entity.
 * @param stairs the stairs entity
 * @param collision_mode the collision mode that detected the event
 */
void CarriedItem::notify_collision_with_stairs(Stairs &stairs, CollisionMode collision_mode) {

  if (is_throwing && !is_breaking
      && stairs.is_inside_floor() && get_layer() == LAYER_LOW) {
    break_on_intermediate_layer = true; // show the destruction animation above the stairs
  }
}
开发者ID:xor-mind,项目名称:solarus,代码行数:12,代码来源:CarriedItem.cpp

示例5: is_stairs_obstacle

/**
 * \copydoc MapEntity::is_stairs_obstacle
 */
bool CustomEntity::is_stairs_obstacle(Stairs& stairs) {

    const TraversableInfo& info = get_can_traverse_entity_info(stairs.get_type());
    if (!info.is_empty()) {
        return !info.is_traversable(*this, stairs);
    }
    return Detector::is_stairs_obstacle(stairs);
}
开发者ID:liyonghelpme,项目名称:solarus,代码行数:11,代码来源:CustomEntity.cpp

示例6: test3

int test3() {
    int maxHeight = 359;
    int minWidth = 1;
    int totalHeight = 720;
    int totalWidth = 720;
    Stairs* pObj = new Stairs();
    clock_t start = clock();
    int result = pObj->designs(maxHeight, minWidth, totalHeight, totalWidth);
    clock_t end = clock();
    delete pObj;
    int expected = 7;
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
开发者ID:rick-qiu,项目名称:topcoder,代码行数:19,代码来源:srm177_stairs.cpp

示例7: is_stairs_obstacle

/**
 * \brief Returns whether some stairs are currently considered as an obstacle for this entity.
 * \param stairs an stairs entity
 * \return true if the stairs are currently an obstacle for this entity
 */
bool Boomerang::is_stairs_obstacle(const Stairs& stairs) const {
  return stairs.is_inside_floor() && get_layer() == LAYER_LOW;
}
开发者ID:bgalok,项目名称:solarus,代码行数:8,代码来源:Boomerang.cpp

示例8: is_stairs_obstacle

/**
 * \brief Returns whether some stairs are currently considered as an obstacle for this entity.
 * \param stairs an stairs entity
 * \return true if the stairs are currently an obstacle for this entity
 */
bool Arrow::is_stairs_obstacle(Stairs& stairs) {
  return stairs.is_inside_floor() && get_layer() == LAYER_LOW;
}
开发者ID:Arseth,项目名称:solarus,代码行数:8,代码来源:Arrow.cpp

示例9: is_stairs_obstacle

/**
 * \brief Returns whether some stairs are currently considered as an obstacle for this entity.
 * \param stairs an stairs entity
 * \return true if the stairs are currently an obstacle for this entity
 */
bool Boomerang::is_stairs_obstacle(Stairs& stairs) {
  return stairs.is_inside_floor() && get_layer() == stairs.get_layer();
}
开发者ID:Codex-NG,项目名称:solarus,代码行数:8,代码来源:Boomerang.cpp


注:本文中的Stairs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。