diff --git a/cmake/.DS_Store b/.DS_Store similarity index 97% rename from cmake/.DS_Store rename to .DS_Store index 5008ddf..9a874b5 100644 Binary files a/cmake/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/src/.main.cpp.swp b/src/.main.cpp.swp deleted file mode 100644 index 24e86fd..0000000 Binary files a/src/.main.cpp.swp and /dev/null differ diff --git a/src/main.cpp b/src/main.cpp index d4bb06e..62c4782 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,26 +1,65 @@ -#include +#include #include +#include +#include +#include + +const int WINDOW_X = 600; +const int WINDOW_Y = 800; -int main(){ +float elap_time(){ + static std::chrono::time_point start; + static bool started = false; + if (!started){ + start = std::chrono::system_clock::now(); + started = true; + } + + std::chrono::time_point now = std::chrono::system_clock::now(); + std::chrono::duration elapsed_time = now - start; + return elapsed_time.count(); +} - sf::RenderWindow window(sf::VideoMode(300, 300), "SFML"); - sf::CircleShape shape(10.0f); - shape.setFillColor(sf::Color::Green); - - while (window.isOpen()) { - sf::Event event; - while (window.pollEvent(event)){ - if (event.type == sf::Event::Closed){ - window.close(); - } - } +int main() { + elap_time(); + std::mt19937 rng(time(NULL)); + std::uniform_int_distribution rgen(100, 400); - window.clear(); - window.draw(shape); - window.display(); + sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML"); + float step_size = 0.005f; + double frame_time = 0.0, elapsed_time = 0.0, delta_time = 0.0, accumulator_time = 0.0, current_time = 0.0; + + + while (window.isOpen()) { + + sf::Event event; + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) + window.close(); } - return 0; + elapsed_time = elap_time(); + delta_time = elapsed_time - current_time; + current_time = elapsed_time; + if (delta_time > 0.02f) + delta_time = 0.02f; + accumulator_time += delta_time; + + while ((accumulator_time - step_size) >= step_size) { + accumulator_time -= step_size; + + // Update(step_size); + } + + window.clear(sf::Color::Black); + + window.display(); + + + + } + return 0; + }