c++求助。。。俄罗斯方块 或者贪吃蛇 代码
急用呀。。等几天就要交作品。完全不会。跪求帮助!只要能基本运行就成。老师给了ColorConsole.h和ColorConsole.cpp。要求必须使用。我的邮箱dqm1...
急用呀。。等几天就要交作品。完全不会。 跪求帮助! 只要能基本运行就成。 老师给了ColorConsole.h 和ColorConsole.cpp。 要求必须使用。 我的邮箱 dqm12315@yahoo.com.cn 。紧急呀!!!
展开
2个回答
展开全部
俄罗斯方块
//russiablock.cpp
#include <stdafx.h>
#include "russiablock.h"
BLOCK::BLOCK()
{
}
BLOCK::BLOCK(const BLOCK &other)
{
for(int index=0;index<4;index++)
{
row[index]=other.row[index];
column[index]=other.column[index];
block[index]=other.block[index];
}
type=other.type;
}
BLOCK &BLOCK::operator =(const BLOCK &other)
{
for(int index=0;index<4;index++)
{
row[index]=other.row[index];
column[index]=other.column[index];
block[index]=other.block[index];
}
type=other.type;
return *this;
}
RUSSIABLOCK::RUSSIABLOCK()
{
field.Initialize(ROW,COLUMN);
field.AllValue(0);
currentblock.type=0;
nextblock.type=0;
srand(unsigned(time(NULL)));
}
RUSSIABLOCK::~RUSSIABLOCK()
{
}
void RUSSIABLOCK::Initialize()
{
field.AllValue(0);
currentblock=CreateBlock();
nextblock=CreateBlock();
}
BLOCK RUSSIABLOCK::CreateBlock()
{
int type;
int mid=(COLUMN+1)/2;
BLOCK block;
type=rand()%19+1;
block.type=type;
switch(type)
{
case 1:
block.row[0]=4;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid-1;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid+2;
break;
case 2:
block.row[0]=1;
block.row[1]=2;
block.row[2]=3;
block.row[3]=4;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 3:
block.row[0]=4;
block.row[1]=4;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 4:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=3;
block.column[0]=mid-1;
block.column[1]=mid-1;
block.column[2]=mid;
block.column[3]=mid+1;
break;
case 5:
block.row[0]=2;
block.row[1]=2;
block.row[2]=3;
block.row[3]=4;
block.column[0]=mid;
block.column[1]=mid+1;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 6:
block.row[0]=3;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid+1;
block.column[2]=mid;
block.column[3]=mid-1;
break;
case 7:
block.row[0]=4;
block.row[1]=4;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid;
block.column[1]=mid+1;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 8:
block.row[0]=3;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid-1;
block.column[1]=mid-1;
block.column[2]=mid;
block.column[3]=mid+1;
break;
case 9:
block.row[0]=2;
block.row[1]=2;
block.row[2]=3;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 10:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=3;
block.column[0]=mid+1;
block.column[1]=mid+1;
block.column[2]=mid;
block.column[3]=mid-1;
break;
case 11:
block.row[0]=4;
block.row[1]=3;
block.row[2]=4;
block.row[3]=3;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 12:
block.row[0]=3;
block.row[1]=3;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid-1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid+1;
break;
case 13:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 14:
block.row[0]=3;
block.row[1]=3;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid-1;
break;
case 15:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid+1;
block.column[1]=mid+1;
block.column[2]=mid;
block.column[3]=mid;
break;
case 16:
block.row[0]=3;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid-1;
block.column[3]=mid+1;
break;
case 17:
block.row[0]=3;
block.row[1]=3;
block.row[2]=2;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 18:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=3;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid-1;
break;
case 19:
block.row[0]=3;
block.row[1]=3;
block.row[2]=4;
block.row[3]=2;
block.column[0]=mid;
block.column[1]=mid+1;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
}
for(int index=0;index<4;index++)
{
block.block[index]=rand()%COLOR+1;
}
return block;
}
void RUSSIABLOCK::TurnBlock(BLOCK &block)
{
switch(block.type)
{
case 1:
block.row[0]-=3;
block.column[0]+=2;
block.row[1]-=2;
block.column[1]+=1;
block.row[2]-=1;
block.column[3]-=1;
block.type=2;
break;
case 2:
block.row[0]+=3;
block.column[0]-=2;
block.row[1]+=2;
block.column[1]-=1;
block.row[2]+=1;
block.column[3]+=1;
block.type=1;
break;
case 3:
block.column[0]-=2;
block.row[1]-=1;
block.column[1]-=1;
block.row[3]+=1;
block.column[3]+=1;
block.type=4;
break;
case 4:
block.row[0]-=2;
block.row[1]-=1;
block.column[1]+=1;
block.row[3]+=1;
block.column[3]-=1;
block.type=5;
break;
case 5:
block.row[0]+=1;
block.column[0]+=2;
block.row[1]+=2;
block.column[1]+=1;
block.row[2]+=1;
block.column[3]-=1;
block.type=6;
break;
case 6:
block.row[0]+=1;
block.column[1]-=1;
block.row[2]-=1;
block.row[3]-=2;
block.column[3]+=1;
block.type=3;
break;
case 7:
block.row[0]-=1;
block.column[1]-=1;
block.row[2]+=1;
block.row[3]+=2;
block.column[3]+=1;
block.type=8;
break;
case 8:
block.row[0]-=1;
block.column[0]+=2;
block.row[1]-=2;
block.column[1]+=1;
block.row[2]-=1;
block.column[3]-=1;
block.type=9;
break;
case 9:
block.row[0]+=2;
block.row[1]+=1;
block.column[1]+=1;
block.row[3]-=1;
block.column[3]-=1;
block.type=10;
break;
case 10:
block.column[0]-=2;
block.row[1]+=1;
block.column[1]-=1;
block.row[3]-=1;
block.column[3]+=1;
block.type=7;
break;
case 11:
break;
case 12:
block.row[0]+=1;
block.column[1]-=1;
block.row[2]-=1;
block.row[3]-=2;
block.column[3]-=1;
block.type=13;
break;
case 13:
block.row[0]-=1;
block.column[1]+=1;
block.row[2]+=1;
block.row[3]+=2;
block.column[3]+=1;
block.type=12;
break;
case 14:
block.row[0]+=1;
block.column[1]+=1;
block.row[2]-=1;
block.row[3]-=2;
block.column[3]+=1;
block.type=15;
break;
case 15:
block.row[0]-=1;
block.column[1]-=1;
block.row[2]+=1;
block.row[3]+=2;
block.column[3]-=1;
block.type=14;
break;
case 16:
block.column[0]+=1;
block.row[1]-=1;
block.row[2]-=2;
block.column[2]+=1;
block.column[3]-=1;
block.type=17;
break;
case 17:
block.row[0]+=1;
block.column[0]-=1;
block.row[2]+=1;
block.column[2]+=1;
block.row[3]-=1;
block.column[3]-=1;
block.type=18;
break;
case 18:
block.row[0]-=1;
block.column[0]-=1;
block.row[2]+=1;
block.column[2]-=1;
block.row[3]-=1;
block.column[3]+=1;
block.type=19;
break;
case 19:
block.column[0]+=1;
block.row[1]+=1;
block.column[2]-=1;
block.row[3]+=2;
block.column[3]+=1;
block.type=16;
break;
}
}
bool RUSSIABLOCK::Move(DIRECTION direction)
{
int index;
switch(direction)
{
case DOWN:
if((currentblock.row[0]-ROW)*(currentblock.row[1]-ROW)*(currentblock.row[2]-ROW)*(currentblock.row[3]-ROW)==0)
{
return false;
}
else if(field(currentblock.row[0]+1,currentblock.column[0])+field(currentblock.row[1]+1,currentblock.column[1])+
field(currentblock.row[2]+1,currentblock.column[2])+field(currentblock.row[3]+1,currentblock.column[3])!=0)
{
return false;
}
for(index=0;index<4;index++)
{
currentblock.row[index]++;
}
if((currentblock.row[0]-ROW)*(currentblock.row[1]-ROW)*(currentblock.row[2]-ROW)*(currentblock.row[3]-ROW)==0 ||
field(currentblock.row[0]+1,currentblock.column[0])+field(currentblock.row[1]+1,currentblock.column[1])+
field(currentblock.row[2]+1,currentblock.column[2])+field(currentblock.row[3]+1,currentblock.column[3])!=0)
{
for(index=0;index<4;index++)
{
field.InMatrix(currentblock.row[index],currentblock.column[index],currentblock.block[index]);
}
currentblock=nextblock;
nextblock=CreateBlock();
}
break;
case LEFT:
if((currentblock.column[0]-1)*(currentblock.column[1]-1)*(currentblock.column[2]-1)*(currentblock.column[3]-1)==0)
{
return false;
}
else if(field(currentblock.row[0],currentblock.column[0]-1)+field(currentblock.row[1],currentblock.column[1]-1)+
field(currentblock.row[2],currentblock.column[2]-1)+field(currentblock.row[3],currentblock.column[3]-1)!=0)
{
return false;
}
for(index=0;index<4;index++)
{
currentblock.column[index]--;
}
break;
case RIGHT:
if((COLUMN-currentblock.column[0])*(COLUMN-currentblock.column[1])*(COLUMN-currentblock.column[2])*
(COLUMN-currentblock.column[3])==0)
{
return false;
}
else if(field(currentblock.row[0],currentblock.column[0]+1)+field(currentblock.row[1],currentblock.column[1]+1)+
field(currentblock.row[2],currentblock.column[2]+1)+field(currentblock.row[3],currentblock.column[3]+1)!=0)
{
return false;
}
for(index=0;index<4;index++)
{
currentblock.column[index]++;
}
break;
}
return true;
}
bool RUSSIABLOCK::Turnable()
{
BLOCK block=currentblock;
TurnBlock(block);
if(block.row[0]*block.row[1]*block.row[2]*block.row[3]==0)
{
return false;
}
else if((ROW-block.row[0]+1)*(ROW-block.row[1]+1)*(ROW-block.row[2]+1)*(ROW-block.row[3]+1)==0)
{
return false;
}
else if(block.column[0]*block.column[1]*block.column[2]*block.column[3]==0)
{
return false;
}
else if((COLUMN-block.column[0]+1)*(COLUMN-block.column[1]+1)*(COLUMN-block.column[2]+1)*(COLUMN-block.column[3]+1)==0)
{
return false;
}
else if(field(block.row[0],block.column[0])+field(block.row[1],block.column[1])+field(block.row[2],block.column[2])+
field(block.row[3],block.column[3])!=0)
{
return false;
}
return true;
}
bool RUSSIABLOCK::End()
{
for(int index=1;index<=COLUMN;index++)
{
if(field(5,index)!=0)
{
return true;
}
}
return false;
}
int RUSSIABLOCK::RemoveLine()
{
int line=0;
int count;
int index1,index2,index;
for(index1=ROW;index1>=5;index1--)
{
count=0;
for(index2=1;index2<=COLUMN;index2++)
{
if(field(index1,index2)!=0)
{
count++;
}
}
if(count==COLUMN)
{
for(index=index1;index>=6;index--)
{
for(index2=1;index2<=COLUMN;index2++)
{
field.InMatrix(index,index2,field(index-1,index2));
}
}
index1++;
line++;
}
}
return line;
}
//russiablock.cpp
#include <stdafx.h>
#include "russiablock.h"
BLOCK::BLOCK()
{
}
BLOCK::BLOCK(const BLOCK &other)
{
for(int index=0;index<4;index++)
{
row[index]=other.row[index];
column[index]=other.column[index];
block[index]=other.block[index];
}
type=other.type;
}
BLOCK &BLOCK::operator =(const BLOCK &other)
{
for(int index=0;index<4;index++)
{
row[index]=other.row[index];
column[index]=other.column[index];
block[index]=other.block[index];
}
type=other.type;
return *this;
}
RUSSIABLOCK::RUSSIABLOCK()
{
field.Initialize(ROW,COLUMN);
field.AllValue(0);
currentblock.type=0;
nextblock.type=0;
srand(unsigned(time(NULL)));
}
RUSSIABLOCK::~RUSSIABLOCK()
{
}
void RUSSIABLOCK::Initialize()
{
field.AllValue(0);
currentblock=CreateBlock();
nextblock=CreateBlock();
}
BLOCK RUSSIABLOCK::CreateBlock()
{
int type;
int mid=(COLUMN+1)/2;
BLOCK block;
type=rand()%19+1;
block.type=type;
switch(type)
{
case 1:
block.row[0]=4;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid-1;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid+2;
break;
case 2:
block.row[0]=1;
block.row[1]=2;
block.row[2]=3;
block.row[3]=4;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 3:
block.row[0]=4;
block.row[1]=4;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 4:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=3;
block.column[0]=mid-1;
block.column[1]=mid-1;
block.column[2]=mid;
block.column[3]=mid+1;
break;
case 5:
block.row[0]=2;
block.row[1]=2;
block.row[2]=3;
block.row[3]=4;
block.column[0]=mid;
block.column[1]=mid+1;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 6:
block.row[0]=3;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid+1;
block.column[2]=mid;
block.column[3]=mid-1;
break;
case 7:
block.row[0]=4;
block.row[1]=4;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid;
block.column[1]=mid+1;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 8:
block.row[0]=3;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid-1;
block.column[1]=mid-1;
block.column[2]=mid;
block.column[3]=mid+1;
break;
case 9:
block.row[0]=2;
block.row[1]=2;
block.row[2]=3;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 10:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=3;
block.column[0]=mid+1;
block.column[1]=mid+1;
block.column[2]=mid;
block.column[3]=mid-1;
break;
case 11:
block.row[0]=4;
block.row[1]=3;
block.row[2]=4;
block.row[3]=3;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 12:
block.row[0]=3;
block.row[1]=3;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid-1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid+1;
break;
case 13:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
case 14:
block.row[0]=3;
block.row[1]=3;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid-1;
break;
case 15:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=2;
block.column[0]=mid+1;
block.column[1]=mid+1;
block.column[2]=mid;
block.column[3]=mid;
break;
case 16:
block.row[0]=3;
block.row[1]=4;
block.row[2]=4;
block.row[3]=4;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid-1;
block.column[3]=mid+1;
break;
case 17:
block.row[0]=3;
block.row[1]=3;
block.row[2]=2;
block.row[3]=4;
block.column[0]=mid+1;
block.column[1]=mid;
block.column[2]=mid;
block.column[3]=mid;
break;
case 18:
block.row[0]=4;
block.row[1]=3;
block.row[2]=3;
block.row[3]=3;
block.column[0]=mid;
block.column[1]=mid;
block.column[2]=mid+1;
block.column[3]=mid-1;
break;
case 19:
block.row[0]=3;
block.row[1]=3;
block.row[2]=4;
block.row[3]=2;
block.column[0]=mid;
block.column[1]=mid+1;
block.column[2]=mid+1;
block.column[3]=mid+1;
break;
}
for(int index=0;index<4;index++)
{
block.block[index]=rand()%COLOR+1;
}
return block;
}
void RUSSIABLOCK::TurnBlock(BLOCK &block)
{
switch(block.type)
{
case 1:
block.row[0]-=3;
block.column[0]+=2;
block.row[1]-=2;
block.column[1]+=1;
block.row[2]-=1;
block.column[3]-=1;
block.type=2;
break;
case 2:
block.row[0]+=3;
block.column[0]-=2;
block.row[1]+=2;
block.column[1]-=1;
block.row[2]+=1;
block.column[3]+=1;
block.type=1;
break;
case 3:
block.column[0]-=2;
block.row[1]-=1;
block.column[1]-=1;
block.row[3]+=1;
block.column[3]+=1;
block.type=4;
break;
case 4:
block.row[0]-=2;
block.row[1]-=1;
block.column[1]+=1;
block.row[3]+=1;
block.column[3]-=1;
block.type=5;
break;
case 5:
block.row[0]+=1;
block.column[0]+=2;
block.row[1]+=2;
block.column[1]+=1;
block.row[2]+=1;
block.column[3]-=1;
block.type=6;
break;
case 6:
block.row[0]+=1;
block.column[1]-=1;
block.row[2]-=1;
block.row[3]-=2;
block.column[3]+=1;
block.type=3;
break;
case 7:
block.row[0]-=1;
block.column[1]-=1;
block.row[2]+=1;
block.row[3]+=2;
block.column[3]+=1;
block.type=8;
break;
case 8:
block.row[0]-=1;
block.column[0]+=2;
block.row[1]-=2;
block.column[1]+=1;
block.row[2]-=1;
block.column[3]-=1;
block.type=9;
break;
case 9:
block.row[0]+=2;
block.row[1]+=1;
block.column[1]+=1;
block.row[3]-=1;
block.column[3]-=1;
block.type=10;
break;
case 10:
block.column[0]-=2;
block.row[1]+=1;
block.column[1]-=1;
block.row[3]-=1;
block.column[3]+=1;
block.type=7;
break;
case 11:
break;
case 12:
block.row[0]+=1;
block.column[1]-=1;
block.row[2]-=1;
block.row[3]-=2;
block.column[3]-=1;
block.type=13;
break;
case 13:
block.row[0]-=1;
block.column[1]+=1;
block.row[2]+=1;
block.row[3]+=2;
block.column[3]+=1;
block.type=12;
break;
case 14:
block.row[0]+=1;
block.column[1]+=1;
block.row[2]-=1;
block.row[3]-=2;
block.column[3]+=1;
block.type=15;
break;
case 15:
block.row[0]-=1;
block.column[1]-=1;
block.row[2]+=1;
block.row[3]+=2;
block.column[3]-=1;
block.type=14;
break;
case 16:
block.column[0]+=1;
block.row[1]-=1;
block.row[2]-=2;
block.column[2]+=1;
block.column[3]-=1;
block.type=17;
break;
case 17:
block.row[0]+=1;
block.column[0]-=1;
block.row[2]+=1;
block.column[2]+=1;
block.row[3]-=1;
block.column[3]-=1;
block.type=18;
break;
case 18:
block.row[0]-=1;
block.column[0]-=1;
block.row[2]+=1;
block.column[2]-=1;
block.row[3]-=1;
block.column[3]+=1;
block.type=19;
break;
case 19:
block.column[0]+=1;
block.row[1]+=1;
block.column[2]-=1;
block.row[3]+=2;
block.column[3]+=1;
block.type=16;
break;
}
}
bool RUSSIABLOCK::Move(DIRECTION direction)
{
int index;
switch(direction)
{
case DOWN:
if((currentblock.row[0]-ROW)*(currentblock.row[1]-ROW)*(currentblock.row[2]-ROW)*(currentblock.row[3]-ROW)==0)
{
return false;
}
else if(field(currentblock.row[0]+1,currentblock.column[0])+field(currentblock.row[1]+1,currentblock.column[1])+
field(currentblock.row[2]+1,currentblock.column[2])+field(currentblock.row[3]+1,currentblock.column[3])!=0)
{
return false;
}
for(index=0;index<4;index++)
{
currentblock.row[index]++;
}
if((currentblock.row[0]-ROW)*(currentblock.row[1]-ROW)*(currentblock.row[2]-ROW)*(currentblock.row[3]-ROW)==0 ||
field(currentblock.row[0]+1,currentblock.column[0])+field(currentblock.row[1]+1,currentblock.column[1])+
field(currentblock.row[2]+1,currentblock.column[2])+field(currentblock.row[3]+1,currentblock.column[3])!=0)
{
for(index=0;index<4;index++)
{
field.InMatrix(currentblock.row[index],currentblock.column[index],currentblock.block[index]);
}
currentblock=nextblock;
nextblock=CreateBlock();
}
break;
case LEFT:
if((currentblock.column[0]-1)*(currentblock.column[1]-1)*(currentblock.column[2]-1)*(currentblock.column[3]-1)==0)
{
return false;
}
else if(field(currentblock.row[0],currentblock.column[0]-1)+field(currentblock.row[1],currentblock.column[1]-1)+
field(currentblock.row[2],currentblock.column[2]-1)+field(currentblock.row[3],currentblock.column[3]-1)!=0)
{
return false;
}
for(index=0;index<4;index++)
{
currentblock.column[index]--;
}
break;
case RIGHT:
if((COLUMN-currentblock.column[0])*(COLUMN-currentblock.column[1])*(COLUMN-currentblock.column[2])*
(COLUMN-currentblock.column[3])==0)
{
return false;
}
else if(field(currentblock.row[0],currentblock.column[0]+1)+field(currentblock.row[1],currentblock.column[1]+1)+
field(currentblock.row[2],currentblock.column[2]+1)+field(currentblock.row[3],currentblock.column[3]+1)!=0)
{
return false;
}
for(index=0;index<4;index++)
{
currentblock.column[index]++;
}
break;
}
return true;
}
bool RUSSIABLOCK::Turnable()
{
BLOCK block=currentblock;
TurnBlock(block);
if(block.row[0]*block.row[1]*block.row[2]*block.row[3]==0)
{
return false;
}
else if((ROW-block.row[0]+1)*(ROW-block.row[1]+1)*(ROW-block.row[2]+1)*(ROW-block.row[3]+1)==0)
{
return false;
}
else if(block.column[0]*block.column[1]*block.column[2]*block.column[3]==0)
{
return false;
}
else if((COLUMN-block.column[0]+1)*(COLUMN-block.column[1]+1)*(COLUMN-block.column[2]+1)*(COLUMN-block.column[3]+1)==0)
{
return false;
}
else if(field(block.row[0],block.column[0])+field(block.row[1],block.column[1])+field(block.row[2],block.column[2])+
field(block.row[3],block.column[3])!=0)
{
return false;
}
return true;
}
bool RUSSIABLOCK::End()
{
for(int index=1;index<=COLUMN;index++)
{
if(field(5,index)!=0)
{
return true;
}
}
return false;
}
int RUSSIABLOCK::RemoveLine()
{
int line=0;
int count;
int index1,index2,index;
for(index1=ROW;index1>=5;index1--)
{
count=0;
for(index2=1;index2<=COLUMN;index2++)
{
if(field(index1,index2)!=0)
{
count++;
}
}
if(count==COLUMN)
{
for(index=index1;index>=6;index--)
{
for(index2=1;index2<=COLUMN;index2++)
{
field.InMatrix(index,index2,field(index-1,index2));
}
}
index1++;
line++;
}
}
return line;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询