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


C++ Fleet::Distance方法代码示例

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


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

示例1: panel_draw_fleet

void panel_draw_fleet() {
    int line = 0;
    char buf[80];
    Fleet *flt = (Fleet*)cur_object;
    int col = cur_game->players[flt->Owner()]->color;
    SDL_Rect screenrec = {800, 12, 224, 24*23};
    screenrec.h = min(int(screenrec.h), 24*(flt->NumShips()+SKIP));
    SDL_FillRect(screen, &screenrec, black);

    sprintf(buf, "Fleet: %s", flt->Name());
    string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);

    if(flt->Target() && flt->Distance() >= 0) {
        sprintf(buf, "Course to %s", flt->Target()->Name());
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
        int eta = flt->Distance();
        if(eta > 1) sprintf(buf, "ETA: %d Days", eta);
        else if(eta == 1) sprintf(buf, "ETA: 1 Day");
        else sprintf(buf, "Would Arrive Today");
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
    }
    else if(flt->Target()) {
        sprintf(buf, "Invalid Course");
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
        int eta = -flt->Distance();
        if(eta > 1) sprintf(buf, "ETA: %d Days", eta);
        else if(eta == 1) sprintf(buf, "ETA: 1 Day");
        else sprintf(buf, "Would Arrive Today");
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
    }
    else if((!flt->Location()) && (!flt->Destination())) {
        sprintf(buf, "Orbiting Star");
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
        sprintf(buf, "%d-Day Orbit", (flt->Period()+255)/256);
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
    }
    else if(!flt->Destination()) {
        sprintf(buf, "Orbiting %s", flt->Location()->Name());
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
        sprintf(buf, "16 Orbits/Day");
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
    }
    else {
        sprintf(buf, "Going to %s", flt->Destination()->Name());
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
        int eta = flt->ArriveTurn() - cur_game->turn;
        if(eta > 1) sprintf(buf, "ETA: %d Days", eta);
        else if(eta == 1) sprintf(buf, "ETA: 1 Day");
        else sprintf(buf, "Arriving Today");
        string_draw(screen, 816, 13+24*(line++), cur_font_black[col], buf);
    }

    for(int ctr=0; ctr < min(int(flt->NumShips()), 23-SKIP); ++ctr) {
        int clr = cur_game->players[flt->GetShip(ctr)->Owner()]->color;
        if(ctr == selection) clr = 8;
        sprintf(buf, "  %s: %s",
                flt->GetShip(ctr)->CName(), flt->GetShip(ctr)->Name());
        string_draw(screen, 816, 13+24*(line++), cur_font_black[clr], buf);
    }

    if(flt->NumShips() > 1) {
        buttlist[PANEL_FLEET][BUTTON_SPLIT] =		9;
    }
    else {
        buttlist[PANEL_FLEET][BUTTON_SPLIT] =		0;
    }

    if(flt->CanLand() && (!flt->Destination())) {
        buttlist[PANEL_FLEET][BUTTON_LAND] =	10;
        mo[BUTTON_LAND] = -1;
    }
    else {
        buttlist[PANEL_FLEET][BUTTON_LAND] =	0;
        SDL_Rect canrec = {800, 768-64*2, 224, 64};
        SDL_FillRect(screen, &canrec, black);
        update(&canrec);
    }
}
开发者ID:steaphangreene,项目名称:cosmos,代码行数:78,代码来源:gui_panel_fleet.cpp


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