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


C++ Paddle::draw方法代码示例

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


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

示例1: display

/* Callback handler for window re-paint event */
void display() {
    glClear(GL_COLOR_BUFFER_BIT);  // Clear the color buffer
    glMatrixMode(GL_MODELVIEW);    // To operate on the model-view matrix
    glLoadIdentity();              // Reset model-view matrix
    paddleRight.move();
    ball.draw();
    paddleRight.draw();
    paddleLeft.draw();

    glutSwapBuffers();  // Swap front and back buffers (of double buffered mode)

    // Animation Control - compute the location for the next refresh
    ball.contactLeft(paddleLeft);
    ball.contactRight(paddleRight);
    ball.move();
    ai.AIPaddleMove(ball);
    //ai2.AIPaddleMove(ball);
    if (ball.didRoundEnd() == 'R') {
        ++scoreRight;
        ball.resetBallPos();
    }
    else if (ball.didRoundEnd() == 'L') {
        ++scoreLeft;
        ball.resetBallPos();
    }
    else
        return;


}
开发者ID:harman666666,项目名称:PONG,代码行数:31,代码来源:MAIN.cpp

示例2: run

    // Il metodo `run` farà partire il game loop.
    void run()
    {
        while(true)
        {
            window.clear(sf::Color::Black);

            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) break;

            // Il tasto `P` gestirà la pausa.
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::P))
            {
                // Prima di mettere/togliere la pausa, controlliamo
                // se il tasto era già stato pressato.
                if(!pausePressedLastFrame)
                {
                    if(state == State::Paused)
                        state = State::InProgress;
                    else if(state == State::InProgress)
                        state = State::Paused;
                }

                pausePressedLastFrame = true;
            }
            else
                pausePressedLastFrame = false;

            // Il tasto `R` farà ricominciare il gioco.
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::R)) restart();

            // Se il gioco è in pausa, non aggiorneremo i game
            // object.
            if(state != State::Paused)
            {
                ball.update();
                paddle.update();
                for(auto& brick : bricks)
                {
                    brick.update();
                    solveBrickBallCollision(brick, ball);
                }

                bricks.erase(
                    std::remove_if(std::begin(bricks), std::end(bricks),
                        [](const auto& mBrick)
                        {
                            return mBrick.destroyed;
                        }),
                    std::end(bricks));

                solvePaddleBallCollision(paddle, ball);
            }

            ball.draw(window);
            paddle.draw(window);
            for(auto& brick : bricks) brick.draw(window);

            window.display();
        }
    }
开发者ID:SuperV1234,项目名称:itcpp2015,代码行数:60,代码来源:p09.cpp


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