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
59
60
61
62
63
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "typedef.h"
#include "wfc.h"
void manage_arguments(int argc, char **argv)
{
int opt;
while((opt = getopt(argc, argv, "hd:s:m:")) != -1)
{
switch(opt)
{
case 'd':
width = atoll(strtok(optarg, "x"));
height = atoll(strtok(NULL, "x"));
break;
case 's':
SEED = atoll(optarg);
break;
case 'm':
SCALE = atoll(optarg);
break;
case 'h':
default:
puts("Usage: wfc [OPTION] [VALUE(S)]...\n");
puts("The options are the following: (No option is mandatory)");
puts("-h Get help");
puts("-d Change width and height of the tilemap, defaut is 30x30");
puts(" args: 2 numbers; width and height seperated by an 'x'");
puts("-s Change the seed, default is time(0)");
puts(" args: 1 number; the seed");
puts("-m Change the number, that the tilemap is scaled by");
puts(" args: 1 number; scaler");
exit(EXIT_SUCCESS);
break;
}
}
}
int main(int argc, char **argv)
{
default_values();
manage_arguments(argc, argv);
srand(SEED);
info("Starting With:\n\tWidth: %ld\n\tHeight: %ld\n\tSeed: %ld\n\tScale: %ld", width, height, SEED, SCALE);
init_wfc();
info("WFC Initialized");
wfc();
info("Tilemap Successfully Generated");
save_wfc();
deinit_wfc();
info("WFC Deinitialized");
return 0;
}
|