41d411354069cf03f31c47cf9f6fa537f72668fb
[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 void badge_main_loop(void) {
17 char menu_buf[MAX_LEVELS][32];
18 FILE *fd = fopen("../badge/jumpnrun/levels.txt", "r");
19
20 int i;
21
22 for(i = 0; i < MAX_LEVELS && fgets(menu_buf[i], sizeof(menu_buf[i]), fd); ++i) {
23 menu_buf[i][strlen(menu_buf[i]) - 1] = '\0';
24 }
25
26 fclose(fd);
27
28 char const *menu[i];
29 for(int j = 0; j < i; ++j) {
30 menu[j] = menu_buf[j];
31 }
32
33 size_t choice = 0;
34 size_t first_visible = 0;
35
36 for(;;) {
37 choice = badge_menu(menu, ARRAY_SIZE(menu), &first_visible, choice);
38 char lvname[256];
39 sprintf(lvname, "../badge/jumpnrun/%s.lvl", menu[choice]);
40
41 jumpnrun_play_level(lvname);
42 }
43 }
This page took 0.054107 seconds and 3 git commands to generate.