-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
58 lines (48 loc) · 1.46 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <algorithm>
#include <chrono>
#include <cmath>
#include <fstream>
#include <iostream>
#include <string_view>
#include <vector>
#include <SDL2/SDL.h>
#include "deps/nlohmann/json.hpp"
#include "deps/yekyam/Args.hpp"
#include "src/Entity.hpp"
#include "src/HandleJSON.hpp"
#include "src/Renderer.hpp"
int main(int argc, char **argv)
{
YAGP::Args args(argc, argv);
if (argc == 1)
{
std::cout << "usage:\n";
std::cout << "./main -in inital_conditions.json -out simulation_frames.json -fps 60 -time 2\n\n";
std::cout << "./main -r simulation_frames.json -fps 60\n\n";
return 0;
}
auto infile = args.get<std::string_view>("-in");
auto outfile = args.get<std::string_view>("-out");
auto simulation_file = args.get<std::string_view>("-r");
auto time = args.get<float>("-time");
auto fps = args.get<int>("-fps");
auto show_timing = args.get<bool>("-v");
if (infile.has_value() && outfile.has_value() && time.has_value() && fps.has_value())
{
bool verbose = show_timing.has_value();
auto res =
export_simulation_to_json(infile.value(), outfile.value(), time.value() * fps.value(), verbose);
if (res != SIMULATION_RESULT::SUCCESS)
{
std::cout << "Couldn't create frames, error\n";
}
return 0;
}
if (!simulation_file.has_value() || !fps.has_value())
{
std::cout << "Error; refer to documentation\n";
return 0;
}
std::vector<std::vector<Entity>> frames = load_frames_from_file(simulation_file.value());
render_frames(frames, fps.value());
}