Loading Falcon_9.cpp +13 −0 Original line number Diff line number Diff line #include <iostream> #include "Falcon_9.h" Falcon_9::Falcon_9() { if (!cabine_texture.loadFromFile("../IMG/cabine1.png")) { std::cerr << strerror(errno) << std::endl; abort(); } cabine.setTexture(cabine_texture); cabine.setRotation(2); cabine.setScale(1, 1.05); cabine.setPosition(0, -40); speed = 5; scope = sf::RectangleShape(sf::Vector2f(20, 20)); scope.setFillColor(sf::Color::Red); Loading @@ -10,6 +22,7 @@ Falcon_9::Falcon_9() void Falcon_9::draw_falcon(sf::RenderWindow &win) { win.draw(cabine); win.draw(scope); } Loading Falcon_9.h +2 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ class Falcon_9 { int speed; sf::RectangleShape scope; sf::Texture cabine_texture; sf::Sprite cabine; public: Falcon_9(); Loading IMG/cabine1.png 0 → 100644 +262 KiB Loading image diff... OpenSpace.cpp +53 −4 Original line number Diff line number Diff line Loading @@ -11,16 +11,26 @@ OpenSpace::OpenSpace() void OpenSpace::set_main_star_position() { Star s; for (int i = 0; i < 1000; ++i) for (int i = 0; i < 300; ++i) { int x, y; x = rand() % 2560; y = rand() % 1440; //нрисовать схему if(rand()%2) { x = rand() % 1600; } else{ x = rand() % 300; x *= -1; } if (rand()%2) { y = rand() % 900; } else{ y = rand() % 180; y *= -1; } s.star_position_x = x; s.star_position_y = y; stars.push_back(s); Loading @@ -35,6 +45,10 @@ void OpenSpace::set_star_position() { move_stars(stars[i].star_position_x, stars[i].star_position_y, i); } else { remove_star(stars[i].star_position_x, stars[i].star_position_y, i); } } } Loading @@ -47,8 +61,10 @@ void OpenSpace::move_stars(float x, float y, int star_num) y *=3; for (int i = 0; i < stars.size(); ++i) { stars[i].star_position_x += x; stars[i].star_position_x += x; stars[i].star_position_y += y; stars[i].star_position_y += y; } } Loading Loading @@ -112,6 +128,39 @@ void OpenSpace::move_all_stars(int movestars) } } void OpenSpace::check_edges() { } void OpenSpace::remove_star(float &x, float &y, int &n) { if(x > 1600 || x < -300 || y > 900 || y < -180) { stars.erase(stars.begin() + n); add_star(); } } void OpenSpace::add_star() { int x, y; x = rand() % 423 + 423; y = rand() % 240 +240; Star s; s.star_position_x = x; s.star_position_y = y; stars.push_back(s); } int OpenSpace::get_star_count() { return stars.size(); } OpenSpace.h +2 −1 Original line number Diff line number Diff line Loading @@ -21,11 +21,12 @@ class OpenSpace { public: OpenSpace(); void add_star(); void remove_star(); void remove_star(float &x, float &y, int &n); bool on_screen(float &x, float &y); void set_main_star_position(); void move_stars(float x, float y, int star_num = 0); void move_all_stars(int movestars); void check_edges(); void set_star_position(); void set_speed(); int get_star_count(); Loading Loading
Falcon_9.cpp +13 −0 Original line number Diff line number Diff line #include <iostream> #include "Falcon_9.h" Falcon_9::Falcon_9() { if (!cabine_texture.loadFromFile("../IMG/cabine1.png")) { std::cerr << strerror(errno) << std::endl; abort(); } cabine.setTexture(cabine_texture); cabine.setRotation(2); cabine.setScale(1, 1.05); cabine.setPosition(0, -40); speed = 5; scope = sf::RectangleShape(sf::Vector2f(20, 20)); scope.setFillColor(sf::Color::Red); Loading @@ -10,6 +22,7 @@ Falcon_9::Falcon_9() void Falcon_9::draw_falcon(sf::RenderWindow &win) { win.draw(cabine); win.draw(scope); } Loading
Falcon_9.h +2 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ class Falcon_9 { int speed; sf::RectangleShape scope; sf::Texture cabine_texture; sf::Sprite cabine; public: Falcon_9(); Loading
OpenSpace.cpp +53 −4 Original line number Diff line number Diff line Loading @@ -11,16 +11,26 @@ OpenSpace::OpenSpace() void OpenSpace::set_main_star_position() { Star s; for (int i = 0; i < 1000; ++i) for (int i = 0; i < 300; ++i) { int x, y; x = rand() % 2560; y = rand() % 1440; //нрисовать схему if(rand()%2) { x = rand() % 1600; } else{ x = rand() % 300; x *= -1; } if (rand()%2) { y = rand() % 900; } else{ y = rand() % 180; y *= -1; } s.star_position_x = x; s.star_position_y = y; stars.push_back(s); Loading @@ -35,6 +45,10 @@ void OpenSpace::set_star_position() { move_stars(stars[i].star_position_x, stars[i].star_position_y, i); } else { remove_star(stars[i].star_position_x, stars[i].star_position_y, i); } } } Loading @@ -47,8 +61,10 @@ void OpenSpace::move_stars(float x, float y, int star_num) y *=3; for (int i = 0; i < stars.size(); ++i) { stars[i].star_position_x += x; stars[i].star_position_x += x; stars[i].star_position_y += y; stars[i].star_position_y += y; } } Loading Loading @@ -112,6 +128,39 @@ void OpenSpace::move_all_stars(int movestars) } } void OpenSpace::check_edges() { } void OpenSpace::remove_star(float &x, float &y, int &n) { if(x > 1600 || x < -300 || y > 900 || y < -180) { stars.erase(stars.begin() + n); add_star(); } } void OpenSpace::add_star() { int x, y; x = rand() % 423 + 423; y = rand() % 240 +240; Star s; s.star_position_x = x; s.star_position_y = y; stars.push_back(s); } int OpenSpace::get_star_count() { return stars.size(); }
OpenSpace.h +2 −1 Original line number Diff line number Diff line Loading @@ -21,11 +21,12 @@ class OpenSpace { public: OpenSpace(); void add_star(); void remove_star(); void remove_star(float &x, float &y, int &n); bool on_screen(float &x, float &y); void set_main_star_position(); void move_stars(float x, float y, int star_num = 0); void move_all_stars(int movestars); void check_edges(); void set_star_position(); void set_speed(); int get_star_count(); Loading