Schussphysik: Schwung des Spielers mit einrechnen, Schüsse auf LCD sichtbarer.
[hackover2013-badge-firmware.git] / badge / jumpnrun / tiles.h
1 #ifndef INCLUDED_JUMPNRUN_TILES_H
2 #define INCLUDED_JUMPNRUN_TILES_H
3
4 #include "../util/fixed_point.h"
5 #include "../util/rectangle.h"
6 #include "../ui/sprite.h"
7
8 #include <stdint.h>
9
10 typedef enum {
11 JUMPNRUN_TILE_TOP = 1,
12 JUMPNRUN_TILE_BOTTOM = 2,
13 JUMPNRUN_TILE_LEFT = 4,
14 JUMPNRUN_TILE_RIGHT = 8
15 } jumpnrun_tile_sides;
16
17 enum {
18 JUMPNRUN_TILE_PIXEL_WIDTH = 5,
19 JUMPNRUN_TILE_PIXEL_HEIGHT = 5
20 };
21
22 typedef struct jumpnrun_tile_position {
23 uint16_t x;
24 uint8_t y;
25 } jumpnrun_tile_position;
26
27 typedef struct jumpnrun_tile_type {
28 uint8_t lethal_sides;
29 badge_sprite sprite;
30 } jumpnrun_tile_type;
31
32 typedef struct jumpnrun_tile {
33 jumpnrun_tile_position pos;
34 uint8_t type;
35 } jumpnrun_tile;
36
37 typedef struct jumpnrun_tile_range {
38 size_t first;
39 size_t last; // actually one past last.
40 } jumpnrun_tile_range;
41
42 static inline fixed_point tile_left (jumpnrun_tile const *tile) { return FIXED_POINT(tile->pos.x * JUMPNRUN_TILE_PIXEL_WIDTH , 0); }
43 static inline fixed_point tile_top (jumpnrun_tile const *tile) { return FIXED_POINT(tile->pos.y * JUMPNRUN_TILE_PIXEL_HEIGHT, 0); }
44 static inline fixed_point tile_right (jumpnrun_tile const *tile) { return fixed_point_add(tile_left(tile), FIXED_POINT(JUMPNRUN_TILE_PIXEL_WIDTH , 0)); }
45 static inline fixed_point tile_bottom(jumpnrun_tile const *tile) { return fixed_point_add(tile_top (tile), FIXED_POINT(JUMPNRUN_TILE_PIXEL_HEIGHT, 0)); }
46
47 /************************************/
48
49 enum {
50 JUMPNRUN_TILE_TYPE_BRICK,
51 JUMPNRUN_TILE_TYPE_SQUARE,
52 JUMPNRUN_TILE_TYPE_TUBE_TOP_LEFT,
53 JUMPNRUN_TILE_TYPE_TUBE_TOP_RIGHT,
54 JUMPNRUN_TILE_TYPE_TUBE_LEFT,
55 JUMPNRUN_TILE_TYPE_TUBE_RIGHT,
56
57 JUMPNRUN_TILE_TYPE_COUNT
58 };
59
60 extern jumpnrun_tile_type const jumpnrun_tile_type_data[JUMPNRUN_TILE_TYPE_COUNT];
61
62 static inline jumpnrun_tile_type const *tile_type(jumpnrun_tile const *tile) {
63 return &jumpnrun_tile_type_data[tile->type];
64 }
65
66 static inline rectangle rect_from_tile(jumpnrun_tile const *tile) {
67 rectangle r = {
68 {
69 tile_left(tile),
70 tile_top(tile)
71 }, {
72 FIXED_POINT(tile_type(tile)->sprite.width , 0),
73 FIXED_POINT(tile_type(tile)->sprite.height, 0)
74 }
75 };
76 return r;
77 }
78
79 #endif
This page took 0.053782 seconds and 5 git commands to generate.