/* * $Id: cacatris.h 1 2006-09-22 16:56:18Z jylam $ * * This program is free software. It commes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What The Fuck You Want * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ #ifndef __CACATRIS_H_ #define __CACATRIS_H_ #include #include #include #include #ifndef M_PI # define M_PI 3.14159265358979323846 #endif #include "cucul.h" #include "caca.h" #define INFO_WIDTH 20 #define FIELD_WIDTH 10 #define FIELD_HEIGHT 20 #define FIELD_CANVAS_WIDTH 20 #define FIELD_CANVAS_HEIGHT 20 #define LEVEL_COUNT 11 unsigned int points[LEVEL_COUNT*4] = { 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 300, 600, 900, 1200, 1500, 1800, 2100, 2400, 2700, 3000, 3300, 1200, 2400, 3600, 4800, 6000, 7200, 8400, 9600, 10800, 12000, 13200 }; unsigned char playfield[FIELD_WIDTH*FIELD_HEIGHT]; static cucul_canvas_t *field, *infos, *screen; unsigned int blocks_palette[] = { CUCUL_BLUE, CUCUL_GREEN, CUCUL_CYAN, CUCUL_RED, CUCUL_MAGENTA, CUCUL_BROWN, CUCUL_LIGHTGRAY }; typedef struct piece_t_ { unsigned int w, h; unsigned int color; unsigned int data[4*4]; } piece_t; void infos_populate(cucul_canvas_t *, unsigned int, unsigned char , unsigned char); void playfield_draw(cucul_canvas_t *); void put_piece(unsigned int, unsigned int, unsigned int, unsigned int); void remove_piece(unsigned int id, unsigned int x, unsigned int y, unsigned int rot); unsigned char movable(unsigned int id, int x, int y, unsigned int rot); unsigned char has_landed(unsigned int id, unsigned int x, unsigned int y, unsigned int rot); unsigned char maybe_remove_line(void); piece_t pieces[] = { /* I, rot 0*/ {4,1, 1, {1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0}}, /* I, rot 1*/ {1,4, 1, {1,0,0,0, 1,0,0,0, 1,0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