#include #define STARTBOARD_X 11 /* X start position of the board on the screen */ #define STARTBOARD_Y 2 /* Y start position of the board on the screen */ #define BOARD_CHAR_LEFT 6 #define BOARD_CHAR_RIGHT 6 #define CRUNCH_CHAR_1 13 #define CRUNCH_COLOR_1 FG_BG(COLOR_BLACK, COLOR_GREY) #define CRUNCH_CHAR_2 32 #define CRUNCH_COLOR_2 FG_BG(COLOR_BLACK, COLOR_BLACK) #define POS_SCORE_X 23 #define POS_SCORE_Y 1 #define POS_LEVEL_X 23 #define POS_LEVEL_Y 7 #define POS_LINES_X 23 #define POS_LINES_Y 13 #define POS_NEXT_X 1 #define POS_NEXT_Y 1 #define NEXT_X (POS_NEXT_X+2) #define NEXT_Y (POS_NEXT_Y+3) void updateScore(); void drawPlayground(); void gameOver(); void gr_drawpiece(sprite *p); void gr_erasepiece(sprite *p); void gr_update_board(); void gr_crunch_line(byte line, byte crunch_char, byte crunch_color); // grahpic board // #include // for sprintf // #include #include "keyboard_input.h" #include "fonts.h" #include "pieces.h" #include "ckboard.h" extern unsigned long score; void right_pad_number(unsigned long number) { ultoa(number, tmp, DECIMAL); int l = (int) strlen(tmp); int offset = 6-l; for(int i=l;i>=0;i--) tmp[i+offset] = tmp[i]; // move to the right for(int i=0;ipiece, p->angle); int px = p->x; int py = p->y; // are we erasing the "next" piece ? if(py==PIECE_IS_NEXT) { px = NEXT_X; py = NEXT_Y; } else { px += STARTBOARD_X; py += STARTBOARD_Y; } for(byte t=0; t<4; t++) { int x = px + data->offset_x; int y = py + data->offset_y; data++; draw_tile((byte)x,(byte)y,EMPTY_GR_CHAR,EMPTY_GR_COLOR); } } // draw a piece on the screen void gr_drawpiece(sprite *p) { tile_offset *data = get_piece_offsets(p->piece, p->angle); int px = p->x; int py = p->y; // are we drawing the "next" piece ? if(py==PIECE_IS_NEXT) { px = NEXT_X; py = NEXT_Y; } else { px += STARTBOARD_X; py += STARTBOARD_Y; } byte piece = p->piece; for(byte t=0; t<4; t++) { int x = px; byte x1 = data->offset_x; x+= (int) x1; int y = py; byte y1 = data->offset_y; y+= (int) y1; data++; /* int x = px + data[t].offset_x; int y = py + data[t].offset_y; */ byte ch = piece_chars[piece]; //piece_chars[p->piece]; byte col = piece_colors[piece]; //piece_colors[p->piece]; draw_tile((byte)x,(byte)y,ch,col); } } // fills the specified line with an empty character void gr_crunch_line(byte line, byte crunch_char, byte crunch_color) { for(byte i=0; i