Probeweise mal mit Flashchip sprechen (Statusregister auslesen)
[hackover2013-badge-firmware.git] / badge / jumpnrun / levels.h
1 #ifndef INCLUDED_JUMPNRUN_LEVEL_H
2 #define INCLUDED_JUMPNRUN_LEVEL_H
3
4 #include "enemies.h"
5 #include "items.h"
6 #include "tiles.h"
7
8 #include <badge/util/rectangle.h>
9
10 #include <drivers/fatfs/ff.h>
11
12 #include <stddef.h>
13 #include <stdio.h>
14
15 typedef struct jumpnrun_level_header {
16 size_t tile_count;
17 size_t item_count;
18 size_t enemy_count;
19 } jumpnrun_level_header;
20
21 typedef struct jumpnrun_level {
22 jumpnrun_level_header header;
23
24 vec2d start_pos;
25
26 jumpnrun_tile *tiles;
27 jumpnrun_item *items;
28 jumpnrun_enemy *enemies;
29 } jumpnrun_level;
30
31 enum {
32 JUMPNRUN_LEVEL_LOAD_OK,
33 JUMPNRUN_LEVEL_LOAD_ERROR
34 };
35
36 size_t jumpnrun_level_count(void);
37 void jumpnrun_levels_dump(void);
38
39 int jumpnrun_load_level_header_from_file(jumpnrun_level *dest, FIL *fd);
40 int jumpnrun_load_level_from_file (jumpnrun_level *dest, FIL *fd);
41
42 // Use stack-local VLAs to store dynamic content.
43 #define JUMPNRUN_LEVEL_MAKE_SPACE(var) \
44 jumpnrun_tile var ## _tiles [var.header.tile_count]; \
45 jumpnrun_item var ## _items [var.header.item_count]; \
46 jumpnrun_enemy var ## _enemies[var.header.enemy_count]; \
47 \
48 var.tiles = var ## _tiles; \
49 var.items = var ## _items; \
50 var.enemies = var ## _enemies;
51
52 #endif
This page took 0.053018 seconds and 5 git commands to generate.