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

Last change on this file since 1111 was 1111, checked in by Jean-Yves Lamoureux, 17 years ago
  • Added preliminary score counting system (ok it sucks), and down key (ok, it sucks as well) (but I'm drunk AHAH)
File size: 4.2 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 20
28#define FIELD_HEIGHT 32
29#define FIELD_CANVAS_WIDTH 40
30#define FIELD_CANVAS_HEIGHT 32
31
32unsigned char playfield[FIELD_WIDTH*FIELD_HEIGHT];
33static cucul_canvas_t *field, *infos, *screen;
34
35unsigned int blocks_palette[] = {
36    CUCUL_COLOR_BLUE,
37    CUCUL_COLOR_GREEN,
38    CUCUL_COLOR_CYAN,
39    CUCUL_COLOR_RED,
40    CUCUL_COLOR_MAGENTA,
41    CUCUL_COLOR_BROWN,
42    CUCUL_COLOR_LIGHTGRAY
43};
44
45typedef struct piece_t_ {
46    unsigned int w, h;
47    unsigned int color;
48    unsigned int data[4*4];
49} piece_t;
50
51
52void infos_populate(cucul_canvas_t *, unsigned int score);
53void playfield_draw(cucul_canvas_t *);
54void put_piece(unsigned int, unsigned int, unsigned int, unsigned int);
55void remove_piece(unsigned int id, unsigned int x, unsigned int y, unsigned int rot);
56unsigned char movable(unsigned int id, int x, int y, unsigned int rot);
57unsigned char has_landed(unsigned int id, unsigned int x, unsigned int y, unsigned int rot);
58unsigned char maybe_remove_line(void);
59
60piece_t pieces[] = {
61    /* I, rot 0*/
62    {4,1,
63     1,
64     {1,1,1,1,
65      0,0,0,0,
66      0,0,0,0,
67      0,0,0,0}},
68    /* I, rot 1*/
69    {1,4,
70     1,
71     {1,0,0,0,
72      1,0,0,0,
73      1,0,0,0,
74      1,0,0,0}},
75    /* I, rot 2*/
76    {4,1,
77     1,
78     {1,1,1,1,
79      0,0,0,0,
80      0,0,0,0,
81      0,0,0,0}},
82    /* I, rot 3*/
83    {1,4,
84     1,
85     {1,0,0,0,
86      1,0,0,0,
87      1,0,0,0,
88      1,0,0,0}},
89    /* J, rot 0*/
90    {3,2,
91     2,
92     {1,0,0,0,
93      1,1,1,0,
94      0,0,0,0,
95      0,0,0,0}},
96    /* J, rot 1*/
97    {2,3,
98     2,
99     {1,1,0,0,
100      1,0,0,0,
101      1,0,0,0,
102      0,0,0,0}},
103    /* J, rot 2*/
104    {3,2,
105     2,
106     {1,1,1,0,
107      0,0,1,0,
108      0,0,0,0,
109      0,0,0,0}},
110    /* J, rot 3*/
111    {2,3,
112     2,
113     {0,1,0,0,
114      0,1,0,0,
115      1,1,0,0,
116      0,0,0,0}},
117    /* L, rot 0*/
118    {3,2,
119     3,
120     {0,0,1,0,
121      1,1,1,0,
122      0,0,0,0,
123      0,0,0,0}},
124    /* L, rot 1*/
125    {2,3,
126     3,
127     {1,0,0,0,
128      1,0,0,0,
129      1,1,0,0,
130      0,0,0,0}},
131    /* L, rot 2*/
132    {3,2,
133     3,
134     {1,1,1,0,
135      1,0,0,0,
136      0,0,0,0,
137      0,0,0,0}},
138    /* L, rot 3*/
139    {2,3,
140     3,
141     {1,1,0,0,
142      0,1,0,0,
143      0,1,0,0,
144      0,0,0,0}},
145    /* O, rot 0*/
146    {2,2,
147     4,
148     {1,1,0,0,
149      1,1,0,0,
150      0,0,0,0,
151      0,0,0,0}},
152    /* O, rot 1*/
153    {2,2,
154     4,
155     {1,1,0,0,
156      1,1,0,0,
157      0,0,0,0,
158      0,0,0,0}},
159    /* O, rot 2*/
160    {2,2,
161     4,
162     {1,1,0,0,
163      1,1,0,0,
164      0,0,0,0,
165      0,0,0,0}},
166    /* O, rot 3*/
167    {2,2,
168     4,
169     {1,1,0,0,
170      1,1,0,0,
171      0,0,0,0,
172      0,0,0,0}},
173    /* S, rot 0*/
174    {3,2,
175     5,
176     {0,1,1,0,
177      1,1,0,0,
178      0,0,0,0,
179      0,0,0,0}},
180    /* S, rot 1*/
181    {2,3,
182     5,
183     {1,0,0,0,
184      1,1,0,0,
185      0,1,0,0,
186      0,0,0,0}},
187    /* S, rot 2*/
188    {3,2,
189     5,
190     {0,1,1,0,
191      1,1,0,0,
192      0,0,0,0,
193      0,0,0,0}},
194    /* S, rot 3*/
195    {2,3,
196     5,
197     {1,0,0,0,
198      1,1,0,0,
199      0,1,0,0,
200      0,0,0,0}},
201    /* T, rot 0*/
202    {3,2,
203     6,
204     {0,1,0,0,
205      1,1,1,0,
206      0,0,0,0,
207      0,0,0,0}},
208    /* T, rot 1*/
209    {2,3,
210     6,
211     {1,0,0,0,
212      1,1,0,0,
213      1,0,0,0,
214      0,0,0,0}},
215    /* T, rot 2*/
216    {3,2,
217     6,
218     {1,1,1,0,
219      0,1,0,0,
220      0,0,0,0,
221      0,0,0,0}},
222    /* T, rot 3*/
223    {2,3,
224     6,
225     {0,1,0,0,
226      1,1,0,0,
227      0,1,0,0,
228      0,0,0,0}},
229    /* Z, rot 0*/
230    {3,2,
231     7,
232     {1,1,0,0,
233      0,1,1,0,
234      0,0,0,0,
235      0,0,0,0}},
236    /* Z, rot 1*/
237    {2,3,
238     7,
239     {0,1,0,0,
240      1,1,0,0,
241      1,0,0,0,
242      0,0,0,0}},
243    /* Z, rot 2*/
244    {3,2,
245     7,
246     {1,1,0,0,
247      0,1,1,0,
248      0,0,0,0,
249      0,0,0,0}},
250    /* Z, rot 3*/
251    {2,3,
252     7,
253     {0,1,0,0,
254      1,1,0,0,
255      1,0,0,0,
256      0,0,0,0}},
257};
258
259
260#endif /* __CACATRIS_H_ */
Note: See TracBrowser for help on using the repository browser.