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


C++ Stone::setDistance方法代码示例

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


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

示例1: glMatrixMode

void
GameScene::initializeGL(int width, int height)
{
    viewport_width = width;
    viewport_height = height;

    this->w = width;
    this->h = height;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(0, w, h, 0, 0, 1);

    if (h > w) {
        glTranslatef(w/2, h/2, 0);
        glRotatef(90, 0, 0, 1);
        glTranslatef(-h/2, -w/2, 0);
        std::swap(h, w);
    }

    masterScale = (float)h / 480. * 1.2;
    width = w = (float)w / masterScale;
    height = h = (float)h / masterScale;

    glClearColor(0, 0, 0, 0);

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    Texture *mainTexture = Texture::l44();
    glBindTexture(GL_TEXTURE_2D, mainTexture->getTextureName());
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    rabbit = new PhysicalRabbit(this, new RabbitSprite(mainTexture), new Sprite(TextureParts::makeCoin(mainTexture)), width, height);
    rabbit->setPosition(width/2, height/2);
    rabbit->getSprite()->setHidden(true);
    rabbit->getSprite()->setDistance(1);

    crosshairs = new Crosshairs(this, mainTexture, width, height);
    crosshairs->setRabbit(rabbit);
    crosshairs->setDistance(0);

    landscape = new Landscape(mainTexture, width, height);
    landscape->setRabbit(rabbit);

    jiggleAnimation = new JiggleAnimation(landscape);

    coin = new Sprite(TextureParts::makeCoin(mainTexture));
    coin->setDistance(1);

    timeDisplay = new TimeDisplay(mainTexture, timeManager);
    timeDisplay->setPosition(width - timeDisplay->getWidth()-10, 10);
    timeDisplay->setDistance(0);

    for (int i=0; i<STONE_COUNT; i++) {
        Stone *stone = new Stone(mainTexture, this, i);
        stone->setDistance(0);
        StoneAnimation *stoneAnimation = new StoneAnimation(stone);
        stoneAnimation->restart();
        stones.push_back(stoneAnimation);
        landscape->addChildFront(stone);
    }

    gameOver = new GameOver(mainTexture);
    gameOver->setPosition(width/2, height/2);
    gameOver->reset();
    landscape->addChildFront(gameOver);

    menu = new Menu(mainTexture, width, height);

    tapHelp = new Sprite(TextureParts::makeHelpTap(mainTexture));
    tapHelp->setPosition(width/2, height/2);
    tapHelp->setPosition(width/2, tapHelp->getHeight()/2 + 40);
    tapHelp->setDistance(0);

    tiltHelp = new Sprite(TextureParts::makeHelpTilt(mainTexture));
    tiltHelp->setPosition(width/2, tiltHelp->getHeight()/2 + 40);
    tiltHelp->setDistance(0);

    restartGameThread();
}
开发者ID:mardy,项目名称:trg2,代码行数:86,代码来源:gamescene.cpp


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