Skip to content

Commit 7f7fdc6

Browse files
committed
Make seed customizable
1 parent ae8e507 commit 7f7fdc6

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

Diff for: src/randomart.c

+34-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "arena.h"
1414
#include "ffmpeg.h"
1515

16-
#define WIDTH 800
17-
#define HEIGHT 600
16+
#define WIDTH 1600
17+
#define HEIGHT 900
1818
#define FPS 60
1919

2020
static Arena static_arena = {0};
@@ -711,9 +711,24 @@ int main(int argc, char **argv)
711711
const char *program_name = shift(argv, argc);
712712

713713
int depth = 40;
714+
int seed = time(0);
715+
716+
while (argc > 0) {
717+
const char *flag = argv[0];
718+
if (strcmp(flag, "-seed") == 0) {
719+
UNUSED(shift(argv, argc));
720+
if (argc <= 0) {
721+
nob_log(ERROR, "No argument is provided for %s", flag);
722+
return 1;
723+
}
724+
seed = atoi(shift(argv, argc));
725+
} else {
726+
break;
727+
}
728+
}
714729

715730
if (argc <= 0) {
716-
nob_log(ERROR, "Usage: %s <command>", program_name);
731+
nob_log(ERROR, "Usage: [options] %s <command>", program_name);
717732
nob_log(ERROR, "No command is provided");
718733
return 1;
719734
}
@@ -728,12 +743,18 @@ int main(int argc, char **argv)
728743
}
729744
const char *output_path = shift(argv, argc);
730745

746+
if (argc > 0) {
747+
nob_log(ERROR, "Usage: %s %s <output-path>", program_name, command_name);
748+
nob_log(ERROR, "%s accepts only 1 argument", command_name);
749+
return 1;
750+
}
751+
731752
Grammar grammar = {0};
732753
int entry = default_grammar(&grammar);
733754

734-
int seed = time(0);
735755
srand(seed);
736-
nob_log(INFO, "SEED: %d\n", seed);
756+
nob_log(INFO, "SEED: %d", seed);
757+
nob_log(INFO, "DEPTH: %d", depth);
737758

738759
Node *f = gen_rule(grammar, entry, depth);
739760
if (!f) {
@@ -749,12 +770,17 @@ int main(int argc, char **argv)
749770
}
750771

751772
if (strcmp(command_name, "gui") == 0) {
773+
if (argc > 0) {
774+
nob_log(ERROR, "%s does not accept any arguments", command_name);
775+
return 1;
776+
}
777+
752778
Grammar grammar = {0};
753779
int entry = default_grammar(&grammar);
754780

755-
int seed = time(0);
756781
srand(seed);
757-
nob_log(INFO, "SEED: %d\n", seed);
782+
nob_log(INFO, "SEED: %d", seed);
783+
nob_log(INFO, "DEPTH: %d", depth);
758784

759785
Node *f = gen_rule(grammar, entry, depth);
760786
if (!f) {
@@ -782,7 +808,7 @@ int main(int argc, char **argv)
782808
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
783809
};
784810
float time = 0.0f;
785-
float max_render_length = 2*PI;
811+
float max_render_length = (2*PI)*4;
786812
bool pause = false;
787813
while (!WindowShouldClose()) {
788814
float w = GetScreenWidth();

0 commit comments

Comments
 (0)