// SFMLgame.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include "Ball.h" using namespace sf; using namespace std; int main() { RenderWindow window{ VideoMode{500,500} ,"Game SFML" }; window.setFramerateLimit(60); Event event; Ball ball(400,300); while (true) //główna pętla gry { window.clear(Color::Black); window.pollEvent(event); //czeka na zdarzenie i wykonuje wszystkie funkcjie wewnątrz if(event.type==Event::Closed) //zamykanie okna { window.close(); break; } window.draw(ball); window.display(); } return 0; } ----------------------------------------------------------------- #pragma once #include using namespace sf; class Ball : public sf::Drawable //mozliwosc rysowania { public: Ball(float bX, float bY); Ball()=delete; ~Ball()=default; private: CircleShape shape; const float ballRadius{ 10.0f }; void draw(RenderTarget& target, RenderStates state) const override; }; --------------------------------------------------------------------- #include "stdafx.h" #include "Ball.h" Ball::Ball(float bX,float bY) { shape.setPosition(bX, bY); shape.setRadius(this->ballRadius); shape.setFillColor(Color::White); shape.setOrigin(this->ballRadius, this->ballRadius); } void Ball::draw(RenderTarget& target, RenderStates state)const { target.draw(this->shape, state); }