Levelreihenfolge, -fixes.
[hackover2013-badge-firmware.git] / mock / badge_main_loop.c
1 #include "badge_main_loop.h"
2
3 #include "jumpnrun/jumpnrun.h"
4 #include "ui/display.h"
5 #include "ui/event.h"
6 #include "ui/menu.h"
7 #include "ui/sprite.h"
8
9 #include <stdint.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <unistd.h>
13
14 #define MAX_LEVELS 1024
15
16 #define PATH_PREFIX "../badge/jumpnrun/levels/"
17
18 void badge_main_loop(void) {
19 char menu_buf[MAX_LEVELS][32];
20 FILE *fd = fopen("levels.txt", "r");
21
22 int i;
23
24 for(i = 0; i < MAX_LEVELS && fgets(menu_buf[i], sizeof(menu_buf[i]), fd); ++i) {
25 menu_buf[i][strlen(menu_buf[i]) - 1] = '\0';
26 }
27
28 fclose(fd);
29
30 char const *menu[i];
31 for(int j = 0; j < i; ++j) {
32 menu[j] = menu_buf[j];
33 }
34
35 uint8_t choice = 0;
36 uint8_t first_visible = 0;
37
38 for(;;) {
39 choice = badge_menu(menu, ARRAY_SIZE(menu), &first_visible, choice);
40 char lvname[256];
41 sprintf(lvname, PATH_PREFIX "%s.lvl", menu[choice]);
42
43 jumpnrun_play_level(lvname);
44 }
45 }
This page took 0.041551 seconds and 5 git commands to generate.