1 #include "item.h"
2 #include "util.h"
3 
4 const int items[] = {
5     // items the user can build
6     GRASS,
7     SAND,
8     STONE,
9     BRICK,
10     WOOD,
11     CEMENT,
12     DIRT,
13     PLANK,
14     SNOW,
15     GLASS,
16     COBBLE,
17     LIGHT_STONE,
18     DARK_STONE,
19     CHEST,
20     LEAVES,
21     TALL_GRASS,
22     YELLOW_FLOWER,
23     RED_FLOWER,
24     PURPLE_FLOWER,
25     SUN_FLOWER,
26     WHITE_FLOWER,
27     BLUE_FLOWER,
28     COLOR_00,
29     COLOR_01,
30     COLOR_02,
31     COLOR_03,
32     COLOR_04,
33     COLOR_05,
34     COLOR_06,
35     COLOR_07,
36     COLOR_08,
37     COLOR_09,
38     COLOR_10,
39     COLOR_11,
40     COLOR_12,
41     COLOR_13,
42     COLOR_14,
43     COLOR_15,
44     COLOR_16,
45     COLOR_17,
46     COLOR_18,
47     COLOR_19,
48     COLOR_20,
49     COLOR_21,
50     COLOR_22,
51     COLOR_23,
52     COLOR_24,
53     COLOR_25,
54     COLOR_26,
55     COLOR_27,
56     COLOR_28,
57     COLOR_29,
58     COLOR_30,
59     COLOR_31
60 };
61 
62 const int item_count = sizeof(items) / sizeof(int);
63 
64 const int blocks[256][6] = {
65     // w => (left, right, top, bottom, front, back) tiles
66     {0, 0, 0, 0, 0, 0}, // 0 - empty
67     {16, 16, 32, 0, 16, 16}, // 1 - grass
68     {1, 1, 1, 1, 1, 1}, // 2 - sand
69     {2, 2, 2, 2, 2, 2}, // 3 - stone
70     {3, 3, 3, 3, 3, 3}, // 4 - brick
71     {20, 20, 36, 4, 20, 20}, // 5 - wood
72     {5, 5, 5, 5, 5, 5}, // 6 - cement
73     {6, 6, 6, 6, 6, 6}, // 7 - dirt
74     {7, 7, 7, 7, 7, 7}, // 8 - plank
75     {24, 24, 40, 8, 24, 24}, // 9 - snow
76     {9, 9, 9, 9, 9, 9}, // 10 - glass
77     {10, 10, 10, 10, 10, 10}, // 11 - cobble
78     {11, 11, 11, 11, 11, 11}, // 12 - light stone
79     {12, 12, 12, 12, 12, 12}, // 13 - dark stone
80     {13, 13, 13, 13, 13, 13}, // 14 - chest
81     {14, 14, 14, 14, 14, 14}, // 15 - leaves
82     {15, 15, 15, 15, 15, 15}, // 16 - cloud
83     {0, 0, 0, 0, 0, 0}, // 17
84     {0, 0, 0, 0, 0, 0}, // 18
85     {0, 0, 0, 0, 0, 0}, // 19
86     {0, 0, 0, 0, 0, 0}, // 20
87     {0, 0, 0, 0, 0, 0}, // 21
88     {0, 0, 0, 0, 0, 0}, // 22
89     {0, 0, 0, 0, 0, 0}, // 23
90     {0, 0, 0, 0, 0, 0}, // 24
91     {0, 0, 0, 0, 0, 0}, // 25
92     {0, 0, 0, 0, 0, 0}, // 26
93     {0, 0, 0, 0, 0, 0}, // 27
94     {0, 0, 0, 0, 0, 0}, // 28
95     {0, 0, 0, 0, 0, 0}, // 29
96     {0, 0, 0, 0, 0, 0}, // 30
97     {0, 0, 0, 0, 0, 0}, // 31
98     {176, 176, 176, 176, 176, 176}, // 32
99     {177, 177, 177, 177, 177, 177}, // 33
100     {178, 178, 178, 178, 178, 178}, // 34
101     {179, 179, 179, 179, 179, 179}, // 35
102     {180, 180, 180, 180, 180, 180}, // 36
103     {181, 181, 181, 181, 181, 181}, // 37
104     {182, 182, 182, 182, 182, 182}, // 38
105     {183, 183, 183, 183, 183, 183}, // 39
106     {184, 184, 184, 184, 184, 184}, // 40
107     {185, 185, 185, 185, 185, 185}, // 41
108     {186, 186, 186, 186, 186, 186}, // 42
109     {187, 187, 187, 187, 187, 187}, // 43
110     {188, 188, 188, 188, 188, 188}, // 44
111     {189, 189, 189, 189, 189, 189}, // 45
112     {190, 190, 190, 190, 190, 190}, // 46
113     {191, 191, 191, 191, 191, 191}, // 47
114     {192, 192, 192, 192, 192, 192}, // 48
115     {193, 193, 193, 193, 193, 193}, // 49
116     {194, 194, 194, 194, 194, 194}, // 50
117     {195, 195, 195, 195, 195, 195}, // 51
118     {196, 196, 196, 196, 196, 196}, // 52
119     {197, 197, 197, 197, 197, 197}, // 53
120     {198, 198, 198, 198, 198, 198}, // 54
121     {199, 199, 199, 199, 199, 199}, // 55
122     {200, 200, 200, 200, 200, 200}, // 56
123     {201, 201, 201, 201, 201, 201}, // 57
124     {202, 202, 202, 202, 202, 202}, // 58
125     {203, 203, 203, 203, 203, 203}, // 59
126     {204, 204, 204, 204, 204, 204}, // 60
127     {205, 205, 205, 205, 205, 205}, // 61
128     {206, 206, 206, 206, 206, 206}, // 62
129     {207, 207, 207, 207, 207, 207}, // 63
130 };
131 
132 const int plants[256] = {
133     // w => tile
134     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 16
135     48, // 17 - tall grass
136     49, // 18 - yellow flower
137     50, // 19 - red flower
138     51, // 20 - purple flower
139     52, // 21 - sun flower
140     53, // 22 - white flower
141     54, // 23 - blue flower
142 };
143 
is_plant(int w)144 int is_plant(int w) {
145     switch (w) {
146         case TALL_GRASS:
147         case YELLOW_FLOWER:
148         case RED_FLOWER:
149         case PURPLE_FLOWER:
150         case SUN_FLOWER:
151         case WHITE_FLOWER:
152         case BLUE_FLOWER:
153             return 1;
154         default:
155             return 0;
156     }
157 }
158 
is_obstacle(int w)159 int is_obstacle(int w) {
160     w = ABS(w);
161     if (is_plant(w)) {
162         return 0;
163     }
164     switch (w) {
165         case EMPTY:
166         case CLOUD:
167             return 0;
168         default:
169             return 1;
170     }
171 }
172 
is_transparent(int w)173 int is_transparent(int w) {
174     if (w == EMPTY) {
175         return 1;
176     }
177     w = ABS(w);
178     if (is_plant(w)) {
179         return 1;
180     }
181     switch (w) {
182         case EMPTY:
183         case GLASS:
184         case LEAVES:
185             return 1;
186         default:
187             return 0;
188     }
189 }
190 
is_destructable(int w)191 int is_destructable(int w) {
192     switch (w) {
193         case EMPTY:
194         case CLOUD:
195             return 0;
196         default:
197             return 1;
198     }
199 }
200