49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
#include "2048.h"
|
|
#include "gui.h"
|
|
#include "tui.h"
|
|
|
|
int main(int argc, char *argv[]) {
|
|
bool tui = false;
|
|
int size_x = 4;
|
|
int size_y = 4;
|
|
for (int i = 0; i < argc; i++) {
|
|
if (!strcmp(argv[i], "--help")) {
|
|
printf("You can pass following arguments: \n--help, \n\--tui\ (not all ui elements are implemented, only for demonstration), \n--x (width, default 4), \n--y (height, default 4)\n");
|
|
return 0;
|
|
}
|
|
if (!strcmp(argv[i], "--tui")) {
|
|
tui = true;
|
|
}
|
|
if (!strcmp(argv[i], "--x")) {
|
|
if (argc >= i) {
|
|
if(sscanf(argv[i+1], "%d", &size_x) != 1){
|
|
printf("invalid input\n");
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
if (!strcmp(argv[i], "--y")) {
|
|
if (argc >= i) {
|
|
if(sscanf(argv[i+1], "%d", &size_y) != 1){
|
|
printf("invalid input\n");
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Game game;
|
|
game = game_init(size_x, size_y);
|
|
if (tui) {
|
|
tui_init();
|
|
tui_loop(&game);
|
|
tui_destroy();
|
|
}
|
|
else {
|
|
gui_init();
|
|
gui_loop(&game);
|
|
gui_destroy();
|
|
}
|
|
game_destroy(&game);
|
|
return 0;
|
|
}
|