Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Ilya83

Pages: [1]
1
General / Im stuck with tutor. #1
« on: January 06, 2014, 11:23:51 pm »
Im new in SFML and Im new in C++ too And I don't even speak engl. (OMG What am I doing in here  :o) Just want to do the video tutor 1 But seems Im stuck. I can't use the "constexpr" So I decided to use just CONST And I got the problem witch i can't solve The problem is "Vector2f velocity". Any help please  :) 
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

using namespace std;
using namespace sf;

const unsigned WINDOW_WIDTH = 800;
const unsigned WINDOW_HEIGHT = 600;
const float BALL_RADIUS = 10.f;
const float BALL_VELOCITY = 8.f;

struct Ball
{
    CircleShape shape;

    Vector2f velocity(-BALL_VELOCITY, -BALL_VELOCITY);

    Ball(float mX, float mY)
    {
        shape.setPosition(mX, mY);
        shape.setRadius(BALL_RADIUS);
        shape.setFillColor(Color::Red);
        shape.setOrigin(BALL_RADIUS, BALL_RADIUS);
    }

    void update(){shape.move(velocity);}
};

int main()
{
    Ball ball(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);

    RenderWindow window(VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Arkanoid-1");
    window.setFramerateLimit(60);

    while(true)
    {
        Event event;
        window.pollEvent(event);

        window.clear(Color::Black);

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

        ball.update();
        window.draw(ball.shape);
        window.display();
    }

    return 0;
}
 

Pages: [1]
anything