本文整理汇总了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;
}
示例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();
}
}