source: cacatris/trunk/src/cacatris.h @ 1756

Last change on this file since 1756 was 1458, checked in by Sam Hocevar, 16 years ago
  • Bwarf, typo in the no warranty clause.
File size: 4.6 KB
Line 
1/*
2 *  $Id: cacatris.h 1 2006-09-22 16:56:18Z jylam $
3 *
4 *  This program is free software. It comes without any warranty, to
5 *  the extent permitted by applicable law. You can redistribute it
6 *  and/or modify it under the terms of the Do What The Fuck You Want
7 *  To Public License, Version 2, as published by Sam Hocevar. See
8 *  http://sam.zoy.org/wtfpl/COPYING for more details.
9 */
10
11#ifndef __CACATRIS_H_
12#define __CACATRIS_H_
13
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include <math.h>
18#ifndef M_PI
19#   define M_PI 3.14159265358979323846
20#endif
21
22
23#include "cucul.h"
24#include "caca.h"
25
26
27#define INFO_WIDTH 20
28#define FIELD_WIDTH 10
29#define FIELD_HEIGHT 20
30#define FIELD_CANVAS_WIDTH 20
31#define FIELD_CANVAS_HEIGHT 20
32
33#define LEVEL_COUNT 11
34
35unsigned int points[LEVEL_COUNT*4] = {
36        40,     80,     120,    160,    200,    240,    280,    320,    360,    400,    440,
37        100,    200,    300,    400,    500,    600,    700,    800,    900,    1000,   1100,
38        300,    600,    900,    1200,   1500,   1800,   2100,   2400,   2700,   3000,   3300,
39        1200,   2400,   3600,   4800,   6000,   7200,   8400,   9600,   10800,  12000,  13200
40};
41
42
43unsigned char playfield[FIELD_WIDTH*FIELD_HEIGHT];
44static cucul_canvas_t *field, *infos, *screen;
45
46unsigned int blocks_palette[] = {
47    CUCUL_BLUE,
48    CUCUL_GREEN,
49    CUCUL_CYAN,
50    CUCUL_RED,
51    CUCUL_MAGENTA,
52    CUCUL_BROWN,
53    CUCUL_LIGHTGRAY
54};
55
56typedef struct piece_t_ {
57    unsigned int w, h;
58    unsigned int color;
59    unsigned int data[4*4];
60} piece_t;
61
62
63void infos_populate(cucul_canvas_t *, unsigned int, unsigned char , unsigned char);
64void playfield_draw(cucul_canvas_t *);
65void put_piece(unsigned int, unsigned int, unsigned int, unsigned int);
66void remove_piece(unsigned int id, unsigned int x, unsigned int y, unsigned int rot);
67unsigned char movable(unsigned int id, int x, int y, unsigned int rot);
68unsigned char has_landed(unsigned int id, unsigned int x, unsigned int y, unsigned int rot);
69unsigned char maybe_remove_line(void);
70
71piece_t pieces[] = {
72    /* I, rot 0*/
73    {4,1,
74     1,
75     {1,1,1,1,
76      0,0,0,0,
77      0,0,0,0,
78      0,0,0,0}},
79    /* I, rot 1*/
80    {1,4,
81     1,
82     {1,0,0,0,
83      1,0,0,0,
84      1,0,0,0,
85      1,0,0,0}},
86    /* I, rot 2*/
87    {4,1,
88     1,
89     {1,1,1,1,
90      0,0,0,0,
91      0,0,0,0,
92      0,0,0,0}},
93    /* I, rot 3*/
94    {1,4,
95     1,
96     {1,0,0,0,
97      1,0,0,0,
98      1,0,0,0,
99      1,0,0,0}},
100    /* J, rot 0*/
101    {3,2,
102     2,
103     {1,0,0,0,
104      1,1,1,0,
105      0,0,0,0,
106      0,0,0,0}},
107    /* J, rot 1*/
108    {2,3,
109     2,
110     {1,1,0,0,
111      1,0,0,0,
112      1,0,0,0,
113      0,0,0,0}},
114    /* J, rot 2*/
115    {3,2,
116     2,
117     {1,1,1,0,
118      0,0,1,0,
119      0,0,0,0,
120      0,0,0,0}},
121    /* J, rot 3*/
122    {2,3,
123     2,
124     {0,1,0,0,
125      0,1,0,0,
126      1,1,0,0,
127      0,0,0,0}},
128    /* L, rot 0*/
129    {3,2,
130     3,
131     {0,0,1,0,
132      1,1,1,0,
133      0,0,0,0,
134      0,0,0,0}},
135    /* L, rot 1*/
136    {2,3,
137     3,
138     {1,0,0,0,
139      1,0,0,0,
140      1,1,0,0,
141      0,0,0,0}},
142    /* L, rot 2*/
143    {3,2,
144     3,
145     {1,1,1,0,
146      1,0,0,0,
147      0,0,0,0,
148      0,0,0,0}},
149    /* L, rot 3*/
150    {2,3,
151     3,
152     {1,1,0,0,
153      0,1,0,0,
154      0,1,0,0,
155      0,0,0,0}},
156    /* O, rot 0*/
157    {2,2,
158     4,
159     {1,1,0,0,
160      1,1,0,0,
161      0,0,0,0,
162      0,0,0,0}},
163    /* O, rot 1*/
164    {2,2,
165     4,
166     {1,1,0,0,
167      1,1,0,0,
168      0,0,0,0,
169      0,0,0,0}},
170    /* O, rot 2*/
171    {2,2,
172     4,
173     {1,1,0,0,
174      1,1,0,0,
175      0,0,0,0,
176      0,0,0,0}},
177    /* O, rot 3*/
178    {2,2,
179     4,
180     {1,1,0,0,
181      1,1,0,0,
182      0,0,0,0,
183      0,0,0,0}},
184    /* S, rot 0*/
185    {3,2,
186     5,
187     {0,1,1,0,
188      1,1,0,0,
189      0,0,0,0,
190      0,0,0,0}},
191    /* S, rot 1*/
192    {2,3,
193     5,
194     {1,0,0,0,
195      1,1,0,0,
196      0,1,0,0,
197      0,0,0,0}},
198    /* S, rot 2*/
199    {3,2,
200     5,
201     {0,1,1,0,
202      1,1,0,0,
203      0,0,0,0,
204      0,0,0,0}},
205    /* S, rot 3*/
206    {2,3,
207     5,
208     {1,0,0,0,
209      1,1,0,0,
210      0,1,0,0,
211      0,0,0,0}},
212    /* T, rot 0*/
213    {3,2,
214     6,
215     {0,1,0,0,
216      1,1,1,0,
217      0,0,0,0,
218      0,0,0,0}},
219    /* T, rot 1*/
220    {2,3,
221     6,
222     {1,0,0,0,
223      1,1,0,0,
224      1,0,0,0,
225      0,0,0,0}},
226    /* T, rot 2*/
227    {3,2,
228     6,
229     {1,1,1,0,
230      0,1,0,0,
231      0,0,0,0,
232      0,0,0,0}},
233    /* T, rot 3*/
234    {2,3,
235     6,
236     {0,1,0,0,
237      1,1,0,0,
238      0,1,0,0,
239      0,0,0,0}},
240    /* Z, rot 0*/
241    {3,2,
242     7,
243     {1,1,0,0,
244      0,1,1,0,
245      0,0,0,0,
246      0,0,0,0}},
247    /* Z, rot 1*/
248    {2,3,
249     7,
250     {0,1,0,0,
251      1,1,0,0,
252      1,0,0,0,
253      0,0,0,0}},
254    /* Z, rot 2*/
255    {3,2,
256     7,
257     {1,1,0,0,
258      0,1,1,0,
259      0,0,0,0,
260      0,0,0,0}},
261    /* Z, rot 3*/
262    {2,3,
263     7,
264     {0,1,0,0,
265      1,1,0,0,
266      1,0,0,0,
267      0,0,0,0}},
268};
269
270
271#endif /* __CACATRIS_H_ */
Note: See TracBrowser for help on using the repository browser.