Skip to content

Commit 4e7b708

Browse files
author
Kim
committed
Add setting of framerate limit from cli
1 parent 86ad51b commit 4e7b708

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

include/Args.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ struct Args
3535
std::optional<int> seed;
3636
bool uninformed;
3737
int grid_size;
38+
int frame_limit;
3839
StartPosition start_position;
3940
};

src/Args.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Args::Args(int argc, char const *argv[])
1010
: grid_size{10}
1111
, initial_pathplanner{NoPathplanner}
1212
, start_position{Corner}
13+
, frame_limit{10}
1314
{
1415
std::vector<std::string> args(argv + 1, argv + argc);
1516

@@ -40,6 +41,7 @@ R"(Usage: gui [options]
4041
-e, --eight-connected Make the generated grid eight-connected.
4142
-u Make the path planners have limited environmental knowledge
4243
-s, --size <size> Set the grid size (default: 10).
44+
-l, --limit <limit> Set the framerate limit (default: 10).
4345
-m, --mode {perfect|maze|random}
4446
Set grid generation mode (default: perfect).
4547
-a, --animate Animate procedure.
@@ -70,6 +72,9 @@ R"(Usage: gui [options]
7072
if (auto [contains, next]{contains_and_next_is_valid("s", "-size")}; contains)
7173
grid_size = std::stoi(next);
7274

75+
if (auto [contains, next]{contains_and_next_is_valid("l", "-limit")}; contains)
76+
frame_limit = std::stoi(next);
77+
7378
if (auto [contains, next]{contains_and_next_is_valid("m", "-mode")}; contains)
7479
{
7580
if (next == "perfect")

src/Gui/Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Gui
1111

1212
Core::Core(Args args_)
1313
{
14-
_window->setFramerateLimit(10);
14+
_window->setFramerateLimit(args_.frame_limit);
1515
const int grid_size{args_.grid_size};
1616
auto grid{std::make_unique<Grid>(grid_size, args_.eight_connected, args_.seed)};
1717
Grid perfect_grid{*grid};

0 commit comments

Comments
 (0)