From 49a8fdaa7604520f47713b337c3ff150ea7d1603 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Mon, 6 Jun 2022 09:40:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(MCU=E8=AF=BE=E8=AE=BE):=20=E8=AF=95?= =?UTF-8?q?=E5=9B=BE=E4=BF=AE=E6=94=B9=E5=AE=9E=E7=8E=B0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MCU/MCU_REAL _FINAL/block.c | 79 +++++++++++++++++++------------------ MCU/MCU_REAL _FINAL/block.h | 2 +- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/MCU/MCU_REAL _FINAL/block.c b/MCU/MCU_REAL _FINAL/block.c index 6d5cc61..db4d175 100644 --- a/MCU/MCU_REAL _FINAL/block.c +++ b/MCU/MCU_REAL _FINAL/block.c @@ -1,9 +1,7 @@ #include "block.h" #include "draw.h" -Group piece; -unsigned char regenPieceFlag = 0; -unsigned char base[8][11]={0}; //x*y +unsigned char base[MAX_X][MAX_Y]={0}; //x*y //0为空 1为下落完成 2为正在下落 void blockInit() { @@ -16,7 +14,7 @@ base[0][2]=1; void blockDestroy() { - piece.type=none; + memset(base, 0, sizeof(base)); } void genPiece() @@ -36,11 +34,13 @@ void genPiece() { if(random % 2 == 0) { - piece.type = two_v; // - } // + base[4][8]=2; // + base[4][9]=2; // + } else { - piece.type = two_h; //// + base[3][8]=2; //// + base[4][8]=2; } } //当三个方块的情况 @@ -48,53 +48,56 @@ void genPiece() { if(random == 0) { - // - piece.type = three_h; // - // + base[4][8]=2; + base[4][9]=2; + base[4][10]=2; } else if(random == 1) { - piece.type = three_v; ////// + base[3][8]=2; + base[4][8]=2; + base[5][8]=2; } else if(random == 2) { - // - piece.type = three_l; //// + base[3][9]=2; + base[3][8]=2; + base[4][8]=2; } else if (random == 3) { - piece.type = three_r; // - } //// + base[4][9]=2; + base[3][8]=2; + base[4][8]=2; + } } //当四个方块的情况 if(len == 3) { - piece.type = four; //// - } //// + base[3][9]=2; + base[4][9]=2; + base[3][8]=2; + base[4][8]=2; + } +} +unsigned char isIegal(unsigned char i,unsigned char j) +{ + if(i>=0&&i=0&&j # include #define MAX_X 8 -#define MAX_Y 8 +#define MAX_Y 12 enum BLK_TP {none,two_h,two_v,three_l,three_r,three_h,three_v,four}; //点 结构体