www.pudn.com > Russian_Diamond(step2).zip > block.cpp


#include "block.h" 
#include  
 
const int numBlocks=7; 
const TUint16 bl_types[4][numBlocks]= 
//  ####     ###      ###     ##     ##      ##      ### 
//             #      #      ##       ##     ##       # 
  {{0x4444, 0x0e20, 0x0740, 0x06c0, 0x0c60, 0x6600, 0xe400}, 
   {0x0f00, 0x0644, 0x4460, 0x4620, 0x2640, 0x6600, 0x8c80}, 
   {0x4444, 0x0470, 0x02e0, 0x06c0, 0x0c60, 0x6600, 0x04e0}, 
   {0x0f00, 0x2260, 0x0622, 0x4620, 0x2640, 0x6600, 0x2620}, 
  }; 
 
int TBlock::BlockCount() 
{ 
  return numBlocks; 
} 
 
TBlock TBlock::Block(int id) 
{ 
  return TBlock(id, 0); 
} 
 
TBlock TBlock::RandomBlock(TInt64 &seed) 
{ 
  return Block(Math::Rand(seed)%numBlocks); 
} 
 
void TBlock::Rotate(int dir) 
{ 
  if (dir>0) iRot++; 
  if (dir<0) iRot+=3; 
  iRot%=4; 
} 
 
TInt8 TBlock::RowMask(int nr) const 
{ 
  return (bl_types[iRot][iType]>>(4*nr))&0xf; 
} 
 
TInt8 TBlock::Color() const 
{ 
  return iType+1; 
}