本文整理汇总了C++中BBox::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::contains方法的具体用法?C++ BBox::contains怎么用?C++ BBox::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBox
的用法示例。
在下文中一共展示了BBox::contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: circle_rectangle_test
bool circle_rectangle_test(Pos circle_xy, int circle_rad, BBox rect) {
Pos rad_duped = Pos(circle_rad, circle_rad);
if (rect.contains(circle_xy + rad_duped) || rect.contains(circle_xy - rad_duped)) {
return true;
}
return circle_line_test(circle_xy, circle_rad, Pos(rect.x1, rect.y1), Pos(rect.x2, rect.y1)) ||
circle_line_test(circle_xy, circle_rad, Pos(rect.x1, rect.y1), Pos(rect.x1, rect.y2)) ||
circle_line_test(circle_xy, circle_rad, Pos(rect.x1, rect.y2), Pos(rect.x2, rect.y2)) ||
circle_line_test(circle_xy, circle_rad, Pos(rect.x2, rect.y1), Pos(rect.x2, rect.y2));
}
示例2: searchInternal
void KdTree::searchInternal(KdNode* node,const BBox& bb,int d,List<VecItem*>& items){
if( node ){
Vec pn = node->item->getPosition();
if( (d==0 && bb.getMinX()<pn.getX()) || bb.getMinY()<pn.getY() ){
searchInternal(node->left,bb,(d+1)%m_k,items);
}
if( bb.contains(pn) ){
items.append( node->item );
}
if( (d==0 && pn.getX()<=bb.getMaxX()) || pn.getY()<=bb.getMaxY() ){
searchInternal(node->right,bb,(d+1)%m_k,items);
}
}
}
示例3: get_itemslotn
static int get_itemslotn(Inventory& inv, const BBox& bbox, int mx, int my) {
if (!bbox.contains(mx, my)) {
return -1;
}
int posx = (mx - bbox.x1) / TILE_SIZE;
int posy = (my - bbox.y1) / TILE_SIZE;
int slot = 5 * posy + posx;
if (slot < 0 || slot >= inv.max_size())
return -1;
return slot;
}
示例4: draw_option
static void draw_option(GameState* gs, const BBox& bbox, bool option_set,
sprite_id sprite, const char* text) {
Colour bbox_col = option_set ? COL_WHITE : COL_FILLED_OUTLINE;
if (bbox.contains(gs->mouse_pos())) {
bbox_col = COL_GOLD;
}
gl_draw_sprite(sprite, bbox.x1, bbox.y1,
COL_WHITE.with_alpha(option_set ? 255 : 100));
/* Draw item name */
gl_printf_bounded(gs->primary_font(), option_set ? COL_WHITE : COL_MID_GRAY,
bbox.x1 + TILE_SIZE * 1.25, bbox.y1 + TILE_SIZE / 2,
bbox.width() - TILE_SIZE, true, "%s", text);
gl_draw_rectangle_outline(bbox, bbox_col);
}
示例5: trigger_events
void IOController::trigger_events(const BBox& playing_area) {
// Loop over all possible keys to find active key states
for (int i = SDLK_FIRST + 1; i < SDLK_LAST; i++) {
IOEventTrigger::trigger_t notrigger = IOEventTrigger::NONE;
if (iostate.key_press_states[i]) {
// Trigger key press events
__trigger_events(notrigger, SDLKey(i), iostate.keymod, false);
} else if (iostate.key_down_states[i]) {
// Trigger key hold events
__trigger_events(notrigger, SDLKey(i), iostate.keymod, true);
}
}
if (playing_area.contains(mouse_x(), mouse_y())) {
if (mouse_left_click() || mouse_left_down()) {
__trigger_events(IOEventTrigger::MOUSE_LEFT_CLICK, SDLKey(0),
iostate.keymod, !mouse_left_click());
}
if (mouse_right_click() || mouse_right_down()) {
__trigger_events(IOEventTrigger::MOUSE_RIGHT_CLICK, SDLKey(0),
iostate.keymod, !mouse_left_click());
}
}
if (iostate.mouse_middleclick || iostate.mouse_middledown) {
__trigger_events(IOEventTrigger::MOUSE_MIDDLE_CLICK, SDLKey(0),
iostate.keymod, !iostate.mouse_middleclick);
}
if (mouse_upwheel()) {
__trigger_events(IOEventTrigger::MOUSE_WHEEL_UP, SDLKey(0),
iostate.keymod, false);
}
if (mouse_downwheel()) {
__trigger_events(IOEventTrigger::MOUSE_WHEEL_DOWN, SDLKey(0),
iostate.keymod, false);
}
if (mouse_downwheel()) {
__trigger_events(IOEventTrigger::MOUSE_WHEEL_DOWN, SDLKey(0),
iostate.keymod, false);
}
}