Witam,
Może ktoś mi wyjaśnić dlaczego według VS zapis w linii 9 jest nieprawidłowy?
Rzekomo ballVelocity nie jest nazwą typu. Jeśli zmienię nawiasy na klamrowe jest ok.
const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;
const float ballRadius = 10.0f;
const float ballVelocity = 8.0f;
struct Ball
{
CircleShape shape;
Vector2f velocity( -ballVelocity, -ballVelocity );
float x() { return shape.getPosition().x; }
float y() { return shape.getPosition().y; }
float left() { return x() - shape.getRadius(); }
float right() { return x() + shape.getRadius(); }
float top() { return y() - shape.getRadius(); }
float bottom() { return y() + shape.getRadius(); }
Ball(float mX, float mY)
{
shape.setPosition(mX, mY);
shape.setRadius(ballRadius);
shape.setFillColor(Color::Red);
shape.setOrigin(ballRadius, ballRadius);
}
void update()
{
shape.move(velocity);
if (left() < 0)
velocity.x = ballVelocity;
if (right() > SCREEN_WIDTH)
velocity.x = -ballVelocity;
if (top() < 0)
velocity.y = ballVelocity;
if (bottom() > SCREEN_HEIGHT)
velocity.y = -ballVelocity;
}
};