{这个我仔细检查了,没多没少 原代码如下,大哥门检查以下 /*************************************************************/ //Define the moving matrix data int nchild_matrix3on[3][3]={{0,1,0},{0,1,1},{0,0,1}}; int nchild_matrix3n[3][3]={{0,1,0},{1,1,0},{1,0,0}}; int nchild_matrix3l[3][3]={{1,0,0},{1,0,0},{1,1,0}}; int nchild_matrix3ol[3][3]={{0,0,1},{0,0,1},{0,1,1}}; int nchild_matrix3t[3][3]={{1,1,1},{0,1,0},{0,1,0}}; int nchild_matrix2d[2][2]={{1,1},{1,1}}; int nchild_matrix4l[4][4]={{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}}; //Define ChildMatrix struct struct childmatrix { int **pChild; int dimention;//judge matrix's dimention };childmatrix child_matrix[7]; //Define ChildMatrix Classclass ChildMatrix { public: childmatrix *pChildmatrix;
static int nchild_matrix3on[3][3]={{0,1,0},{0,1,1},{0,0,1}}; static int nchild_matrix3n[3][3]={{0,1,0},{1,1,0},{1,0,0}}; static int nchild_matrix3l[3][3]={{1,0,0},{1,0,0},{1,1,0}}; static int nchild_matrix3ol[3][3]={{0,0,1},{0,0,1},{0,1,1}}; static int nchild_matrix3t[3][3]={{1,1,1},{0,1,0},{0,1,0}}; static int nchild_matrix2d[2][2]={{1,1},{1,1}}; static int nchild_matrix4l[4][4]={{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}};
原代码如下,大哥门检查以下
/*************************************************************/
//Define the moving matrix data
int nchild_matrix3on[3][3]={{0,1,0},{0,1,1},{0,0,1}};
int nchild_matrix3n[3][3]={{0,1,0},{1,1,0},{1,0,0}};
int nchild_matrix3l[3][3]={{1,0,0},{1,0,0},{1,1,0}};
int nchild_matrix3ol[3][3]={{0,0,1},{0,0,1},{0,1,1}};
int nchild_matrix3t[3][3]={{1,1,1},{0,1,0},{0,1,0}};
int nchild_matrix2d[2][2]={{1,1},{1,1}};
int nchild_matrix4l[4][4]={{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}}; //Define ChildMatrix struct
struct childmatrix
{
int **pChild;
int dimention;//judge matrix's dimention
};childmatrix child_matrix[7]; //Define ChildMatrix Classclass ChildMatrix
{
public:
childmatrix *pChildmatrix;
public:
ChildMatrix(childmatrix *pChildmatrix=NULL);
childmatrix *SetChild(childmatrix *pChildmatrix=NULL);
void InitData();
void UnitMatrix(int** Matrix,childmatrix *pChildmatrix,int currentx,int currenty);
BOOL IfCandown(int** Matrix,childmatrix *pChildmatrix,int currentx,int currenty);
BOOL IfCanleft(int** Matrix,childmatrix *pChildmatrix,int currentx,int currenty);
BOOL IfCanright(int** Matrix,childmatrix *pChildmatrix,int currentx,int currenty);
BOOL IfCanRotate(int** Matrix,childmatrix *pChildmatrix,int currentx,int currenty);
void RotateCldMtr(int** Matrix,childmatrix *pChildmatrix,int currentx,int currenty);
void DelFullLine(int** Matrix,childmatrix *pChildmatrix);
};
#include "ChildMatrix.h"void ChildMatrix::InitData()
{
child_matrix[0].pChild =(int **)nchild_matrix3on;
child_matrix[0].dimention=3; child_matrix[1].pChild=(int **)nchild_matrix3n;
child_matrix[1].dimention=3; child_matrix[2].pChild = (int **)nchild_matrix3l;
child_matrix[2].dimention=3; child_matrix[3].pChild=(int **)nchild_matrix3ol;
child_matrix[3].dimention=3; child_matrix[4].pChild=(int **)nchild_matrix3t;
child_matrix[4].dimention=3;
child_matrix[5].pChild=(int **)nchild_matrix2d;
child_matrix[5].dimention=2; child_matrix[6].pChild=(int **)nchild_matrix4l;
child_matrix[6].dimention=4;
}ChildMatrix::ChildMatrix(childmatrix *pChildmatrix=NULL)
{
this->pChildmatrix=pChildmateix;
}void ChildMatrix::UnitMatrix(int **Matrix,childmatrix *pChildmatrix,int currentx,int currenty)
{
for(int i=0;i< pChildmatrix->dimention;i++)
for(int j=0;j<pChildmatrix->dimention;j++)
{
if(currenty+pChildmatrix->dimention>19||currenty<0||currentx+i>29)
break;
else
Matrix[currentx+i][currenty+j]=pChildmatrix->pChild[i][j];
}
}void ChildMatrix::RotateCldMtr(int **Matrix,childmatrix *pChildmatrix,int currentx,int currenty)
{
int i,j;
for(i=0;i<pChildmatrix->dimention;i++) for(j=0;j<pChildmatrix->dimention;j++)
{
int temp=pChildmatrix->pChild[i][j];
pChildmatrix->pChild[i][j]=pChildmatrix->pChild[j][pChildmatrix->dimention-i];
pChildmatrix->pChild[j][pChildmatrix->dimention-i]=temp;
}}BOOL ChildMatrix::IfCandown(int **Matrix,childmatrix *pChildmatrix,int currentx,int currenty)
{
int judge=0;
int temp=pChildmatrix->dimention;
for(int j=0;j<temp;j++)
{
if(currentx+temp-1<30)
{
if(!(Matrix[currentx+temp-1][currenty+j]&pChildmatrix->pChild[temp-1][j]))
judge++;
}
if(pChildmatrix->pChild[temp-1][j]==0)
judge++;
}
if(judge==temp)
return true;
else
return false;
}BOOL ChildMatrix::IfCanleft(int **Matrix,childmatrix *pChildmatrix,int currentx,int currenty)
{
int judge=0;
int temp=pChildmatrix->dimention;
for(int i=0;i<temp;i++)
{
if(currenty>=0)
{
if(!(Matrix[currentx+i][currenty]&pChildmatrix->pChild[i][0]))
judge++;
}
else
if(pChildmatrix->pChild[i][0]==0)
judge++;
}
if(judge==temp)
return true;
else
return false;
}BOOL ChildMatrix::IfCanright(int **Matrix,childmatrix *pChildmatrix,int currentx,int currenty)
{
int judge=0;
int temp=pChildmatrix->dimention;
for(int i=0;i<temp;i++)
{
if(currenty<20)
{
if(!(Matrix[currentx+i][currenty+temp-1]&pChildmatrix->pChild[i][temp-1]))
judge++;
}
else
if(pChildmatrix->pChild[i][temp-1]==0)
judge++;
}
if(judge==temp)
return true;
else
return false;
}BOOL ChildMatrix::IfCanRotate(int **Matrix,childmatrix *pChildmatrix,int currentx,int currenty)
{
int judge=0;
int tempy=currenty;
int tempx=currentx;
tempy=tempy? tempy:0;
tempy=tempy>=20-pChildmatrix->dimention? (20-pChildmatrix->dimention):tempy;
tempx=tempx>=30-pChildmatrix->dimention? (30-pChildmatrix->dimention):tempx;
for(int i=0;i<pChildmatrix->dimention;i++)
{
for(int j=0;j<pChildmatrix->dimention;j++)
if(Matrix[tempx+i][tempy+j]==0)
judge++; } if(judge==pChildmatrix->dimention*pChildmatrix->dimention)
return true;
else
return false;
}void ChildMatrix::DelFullLine(int **Matrix,childmatrix *pChildmatrix)
{
int judge=0;
for(int i=29;i>=0;)
{
for(int j=0;j<20;j++)
{
if(Matrix[i][j]==1)
judge++;
else
break;
}
if(judge==20)
{
for(int l=i;l>=0;l--)
for(int k=0;k<20;k++)
Matrix[l][k]=Matrix[l-1][k];
}
else
i--;
judge=0;
}
}childmatrix *ChildMatrix::SetChild(childmatrix *pChildmatrix=NULL)
{
this->pChildmatrix=pChildmatrix;
return pChildmatrix;
}
static int nchild_matrix3n[3][3]={{0,1,0},{1,1,0},{1,0,0}};
static int nchild_matrix3l[3][3]={{1,0,0},{1,0,0},{1,1,0}};
static int nchild_matrix3ol[3][3]={{0,0,1},{0,0,1},{0,1,1}};
static int nchild_matrix3t[3][3]={{1,1,1},{0,1,0},{0,1,0}};
static int nchild_matrix2d[2][2]={{1,1},{1,1}};
static int nchild_matrix4l[4][4]={{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}};
说不定就没这错误了!!
我就遇到过这情况!!
先试试threads()的方法,不行就rebuild all,还不行就看书去!
#include "stdafx.h"
#include "stdafx.h"
就可以了