本文整理汇总了C++中sf::CircleShape::move方法的典型用法代码示例。如果您正苦于以下问题:C++ CircleShape::move方法的具体用法?C++ CircleShape::move怎么用?C++ CircleShape::move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::CircleShape
的用法示例。
在下文中一共展示了CircleShape::move方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestBox
TestBox(bool isCollidable) :
sg::Entity(isCollidable)
{
r0.setSize(sf::Vector2f(100.0f, 50.0f));
r0.setOrigin(50.0f, 25.0f);
this->addDrawable(r0, false);
bs.addShape(r0);
r1.setRadius(40.0f);
r1.setOrigin(40.0f, 40.0f);
r1.move(100.0f, 0.0f);
r1.scale(2.0f, 1.0f);
this->addDrawable(r1, false);
bs.addShape(r1);
r2.setSize(sf::Vector2f(250.0f, 10.0f));
r2.setOrigin(125.0f, 5.0f);
r2.rotate(-90.0f);
this->addDrawable(r2, false);
bs.addShape(r2);
r3.setRadius(40.0f);
r3.setOrigin(40.0f, 40.0f);
r3.move(-100.0f, 0.0f);
this->addDrawable(r3, false);
bs.addShape(r3);
//bs.rotate(-45.0f);
this->addTransformable(bs);
//this->rotate(45.0f);
}
示例2: update
void update()
{
// Le classi shape di SFML hanno un metodo `move` che
// prende come parametro un vettore `float` di offset.
// {Info: ball movement}
shape.move(velocity);
}
示例3: update
void update()
{
// We need to keep the ball "inside the window".
// The most common (and probably best) way of doing this, and
// of dealing with any kind of collision detection, is moving
// the object first, then checking if it's intersecting
// something.
// If the test is positive, we simply respond to the collision
// by altering the object's position and/or velocity.
// Therefore, we begin by moving the ball.
shape.move(velocity);
// After the ball has moved, it may be "outside the window".
// We need to check every direction and respond by changing
// the velocity.
// If it's leaving towards the left, we need to set
// horizontal velocity to a positive value (towards the right).
if(left() < 0) velocity.x = defVelocity;
// Otherwise, if it's leaving towards the right, we need to
// set horizontal velocity to a negative value (towards the
// left).
else if(right() > wndWidth) velocity.x = -defVelocity;
// The same idea can be applied for top/bottom collisions.
if(top() < 0) velocity.y = defVelocity;
else if(bottom() > wndHeight) velocity.y = -defVelocity;
}
示例4: update
// Atualiza o objeto movendo com a velocidade atual;
void update () {
shape.move (velocity);
// Pra manter a bola dentro da tela, precisamos testar se está nas
// extremidades da tela e inverter sua velocidade
if (left() < 0 || right() > windowWidth) velocity.x *= -1;
if (top() < 0 || bottom() > windowHeight) velocity.y *= -1;
}
示例5: update
void update(sf::Time timeChange)
{
sf::Vector2f p1Movement(0, 0);
sf::Vector2f p2Movement(0, 0);
if (p1MovingUp)
p1Movement.y -= paddleSpeed;
if (p1MovingDown)
p1Movement.y += paddleSpeed;
if (p2MovingUp)
p2Movement.y -= paddleSpeed;
if (p2MovingDown)
p2Movement.y += paddleSpeed;
p1Paddle.move(p1Movement * timeChange.asSeconds());
p2Paddle.move(p2Movement * timeChange.asSeconds());
// Check collision
if (ball.getPosition().y < 0 || ball.getPosition().y > 480){
ballMovement.y *= -1;
}
if (ball.getGlobalBounds().intersects(p1Paddle.getGlobalBounds()) || ball.getGlobalBounds().intersects(p2Paddle.getGlobalBounds())){
ballMovement.x *= -1;
}
// Scoring
if (ball.getPosition().x > 600){
// P1 scores
ball.setPosition(300, 240);
p1Score++;
p1ScoreText.setString(std::to_string(p1Score));
}
else if (ball.getPosition().x < 0){
// P2 scores
ball.setPosition(300, 240);
p2Score++;
p2ScoreText.setString(std::to_string(p2Score));
}
ball.move(ballMovement * timeChange.asSeconds());
}
示例6: update
void Game::update() {
posicion_jugable_x = mPlayer.getPosition().x;
posicion_jugable_y = mPlayer.getPosition().y;
this->movement.y = 0.f;
this->movement.x = 0.f;
if (this->mIsMovingUp & this->mIsMovingUpRel & (posicion_jugable_y > 0) & movimiento_valido(0, -1)) {
this->movement.y -= 50.f;
this->mIsMovingUpRel = 0;
}
if (this->mIsMovingDown & this->mIsMovingDownRel & (posicion_jugable_y < 450) & movimiento_valido(0, 1)) {
this->movement.y += 50.f;
this->mIsMovingDownRel = 0;
}
if (this->mIsMovingLeft & this->mIsMovingLeftRel & (posicion_jugable_x > 0) & movimiento_valido(-1, 0)) {
this->movement.x -= 50.f;
this->mIsMovingLeftRel = 0;
}
if (this->mIsMovingRight & this->mIsMovingRightRel & (posicion_jugable_x < 650) & movimiento_valido(1, 0)) {
this->movement.x += 50.f;
this->mIsMovingRightRel = 0;
}
if(mPlayer.getPosition() == mPlayerObj.getPosition()) {
this->mIsMapGenerate = true;
Game::generacion_mapa();
}
mPlayer.move(this->movement);
}
示例7: ReceiveThread
void ReceiveThread(SOCKET &ConnectSocket)
{
char recvbuf[DEFAULT_BUFLEN];
int iResult;
int recvbuflen = DEFAULT_BUFLEN;
while (1)
{
memset(recvbuf, 0, sizeof(recvbuf));
iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
if (iResult > 0)
{
printf("%s\n", recvbuf);
shape.move(atoi(recvbuf), 0);
}
else if (iResult == 0)
printf("Connection closed\n");
else
printf("recv failed with error: %d\n", WSAGetLastError());
memset(recvbuf, 0, recvbuflen);
}
}
示例8: update
void update()
{
shape.move(velocity);
solveBoundCollisions();
}
示例10: move_by
void move_by(T p)
{
circ.move(p);
sprite.move(p);
vision_aura.move(p);
}