1 /* 2 * Alizarin Tetris 3 * The piece definition structures. 4 * 5 * Copyright 2000, Kiri Wagstaff & Westley Weimer 6 */ 7 #ifndef __PIECE_H 8 #define __PIECE_H 9 10 /* this structure describes a piece layout in the abstract: it has four "x 11 * by y" bitmaps, one for each rotation. Within the bitmap, 0 means 12 * "nothing there" and 1...Z means "tile N is there". All of the bitmaps 13 * have the same upper-left corner (conceptually), and to find what is at 14 * location (i,j) of rotation r, you would use: 15 */ 16 #define BITMAP(p,r,x,y) ((p).bitmap[(r)])[((p).dim)*(y)+(x)] 17 typedef struct piece_struct { 18 int dim; /* width/height in color-tile "units" */ 19 int num_color; /* number of color-tile "units" here */ 20 unsigned char *bitmap[4]; 21 } piece; 22 23 /* a piece_style contains a number of different pieces (as declared above) 24 * and a name. 25 */ 26 typedef struct piece_style_struct { 27 char *name; /* the name of the style */ 28 int num_piece; /* number of pieces */ 29 piece * shape; /* the piece shape */ 30 } piece_style; 31 32 /* "piece_styles" contains all of the styles we have been able to load for 33 * this game. 34 */ 35 typedef struct piece_styles_struct { 36 int num_style; 37 int choice; 38 piece_style **style; 39 } piece_styles; 40 41 /* is this piece a "special" piece that will have extra powers when it 42 * lands? */ 43 typedef enum { 44 No_Special = -1, 45 Special_Bomb = 0, 46 Special_Repaint = 1, 47 Special_Pushdown = 2, 48 Special_Colorkill = 3, 49 } special_type; 50 51 /* a piece that will be presented to the player, instantiated from a piece 52 * style */ 53 typedef struct play_piece_struct { 54 piece * base; 55 unsigned char colormap[12]; 56 special_type special; 57 } play_piece; 58 59 /* a color style holds a number of surfaces that are used to draw in the 60 * tiles that make up pieces */ 61 typedef struct color_style_struct { 62 char *name; /* the name of the style */ 63 int num_color; /* number of colors defined */ 64 SDL_Surface **color; /* surfaces for the colors */ 65 /* note that the colors go from 1 to "num_color" inclusive! */ 66 int w; /* width of each color block */ 67 int h; /* height of each color block */ 68 } color_style; 69 70 color_style special_style; 71 72 #define HORIZ_LIGHT 0 73 #define VERT_LIGHT 1 74 #define HORIZ_DARK 2 75 #define VERT_DARK 3 76 SDL_Surface *edge[4]; /* hikari to kage */ 77 78 /* this structure holds all of the color styles we have been able to load 79 * for this game */ 80 typedef struct color_styles_struct { 81 int num_style; 82 int choice; 83 color_style **style; 84 } color_styles; 85 86 /* random number. ZEROTO(5)=0,1,2,3,4 */ 87 #define ZEROTO(x) (FastRandom(x)) 88 89 #include "piece.pro" 90 91 #endif 92 93 /* 94 * $Log: piece.h,v $ 95 * Revision 1.10 2000/11/06 04:06:44 weimer 96 * option menu 97 * 98 * Revision 1.9 2000/11/06 01:25:54 weimer 99 * add in the other special piece 100 * 101 * Revision 1.8 2000/11/06 00:24:01 weimer 102 * add WalkRadioGroup modifications (inactive field for Kiri) and some support 103 * for special pieces 104 * 105 * Revision 1.7 2000/11/03 03:41:35 weimer 106 * made the light and dark "edges" of pieces global, rather than part of a 107 * specific color style. also fixed a bug where we were updating too much 108 * when drawing falling pieces (bad min() code on my part) 109 * 110 * Revision 1.6 2000/10/29 00:17:39 weimer 111 * added support for a system independent random number generator 112 * 113 * Revision 1.5 2000/10/21 01:14:43 weimer 114 * massic autoconf/automake restructure ... 115 * 116 * Revision 1.4 2000/09/04 19:48:02 weimer 117 * interim menu for choosing among game styles, button changes (two states) 118 * 119 * Revision 1.3 2000/09/03 18:26:11 weimer 120 * major header file and automatic prototype generation changes, restructuring 121 * 122 * Revision 1.2 2000/08/13 19:27:20 weimer 123 * added file changelogs 124 * 125 */ 126