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

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