Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <iostream>
- #define H 800
- #define W 800
- #define D 10
- #define pi 3.14159265359
- int A = 1;
- int f = 10;
- float T = 0.1;
- float fp = 10000;
- using namespace std;
- int main()
- {
- int xx[] = { D,D,W - D,W - D,D };
- int yy[] = { D,H - D,H - D,D,D };
- // Create the main window
- sf::RenderWindow window(sf::VideoMode(800, 800), "SFML window");
- sf::VertexArray linie(sf::Lines);
- for (int i = 0; i<4; i++)
- {
- linie.append(sf::Vector2f(xx[i], yy[i])); // poczΔ tek
- linie.append(sf::Vector2f(xx[i + 1], yy[i + 1])); // koniec
- };
- sf::VertexArray wspolrzedne(sf::Lines);
- wspolrzedne.append(sf::Vector2f(D, H / 2));
- wspolrzedne.append(sf::Vector2f(W - D, H / 2));
- int N = T*fp + 1;
- float* y;
- y = new float[N];
- int Bx = D;
- int Ax = (W - 2 * D) / T;
- int Ay = (H - 2 * D) / (-2 * A);
- int By = (D - Ay*A);
- sf::VertexArray points(sf::Points);
- int i = 0;
- for (float t = 0; t <= T; t = t + (1/fp)) {
- cout << "Pi: " << t << endl;
- float x = sin(2 * pi *f*t);
- y[i] = (A*x);
- points.append(sf::Vector2f(Ax*t + Bx, Ay*y[i] + By));
- }
- // Start the game loop
- while (window.isOpen())
- {
- // Process events
- sf::Event event;
- while (window.pollEvent(event))
- {
- // Close window : exit
- if (event.type == sf::Event::Closed)
- window.close();
- }
- // Clear screen
- window.clear();
- window.draw(linie);
- window.draw(wspolrzedne);
- window.draw(points);
- // Update the window
- window.display();
- }
- delete[] y;
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment