Esempio n. 1
0
 /*!
 **\brief Sets the 3 atoms in the angle
 **\param atoms a triple of OBAtom pointers, the first must be the vertex
 */
 void OBAngle::SetAtoms(triple<OBAtom*,OBAtom*,OBAtom*> &atoms)
 {
   _vertex         = atoms.first;
   _termini.first  = atoms.second;
   _termini.second = atoms.third;
   SortByIndex();
   return;
 }
Esempio n. 2
0
 /*!
 **\brief Sets the 3 atoms in the angle
 ** Parameters are pointers to each OBAtom
 */
 void OBAngle::SetAtoms(OBAtom *vertex,OBAtom *a,OBAtom *b)
 {
   _vertex         = vertex;
   _termini.first  = a;
   _termini.second = b;
   SortByIndex();
   return;
 }
Esempio n. 3
0
 /*!
 **\brief Angle constructor
 */
 OBAngle::OBAngle(OBAtom *vertex,OBAtom *a,OBAtom *b):
   _vertex(vertex), _termini(a, b)
 {
   SortByIndex();
 }
void CGameFrameWork::MoveBlock()
{
	SortByIndex();

	vector<Tile*> tile = dynamic_cast<CBoard*>(m_pBoard)->GetTile();

	for (auto p = m_vecBlock.begin(); p != m_vecBlock.end(); ++p)
	{
		int idx = dynamic_cast<CBlock*>(*p)->GetBlockInfo().index;

		if (m_eKeyDir == KEY_LEFT)
		{
			if (idx % 4 != 0)
			{
				if (tile[idx - 1]->option == 0)
				{
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx - 1, 1);

					dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
					dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx - 1);
					dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(-10, 0));
				}

				else if (tile[idx - 1]->option == 1)
				{
					CObj* currBlock = FindBlock(idx);
					CObj* nextBlock = FindBlock(idx - 1);

					if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().value
						== dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().value)
					{
						if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().addCheck == 0
							&& dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().addCheck == 0)
						{
							dynamic_cast<CBlock*>(currBlock)->SetBlockAddCheck(1);
							dynamic_cast<CBlock*>(nextBlock)->SetBlockAddCheck(2);

							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx - 1, 1);

							dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
							dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx - 1);
							dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(-10, 0));
						}
					}
				}
			}
		}

		else if (m_eKeyDir == KEY_RIGHT)
		{
			if (idx % 4 != 3)
			{
				if (tile[idx + 1]->option == 0)
				{
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx + 1, 1);

					dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
					dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx + 1);
					dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(10, 0));
				}

				else if (tile[idx + 1]->option == 1)
				{
					CObj* currBlock = FindBlock(idx);
					CObj* nextBlock = FindBlock(idx + 1);

					if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().value
						== dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().value)
					{
						if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().addCheck == 0
							&& dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().addCheck == 0)
						{
							dynamic_cast<CBlock*>(currBlock)->SetBlockAddCheck(1);
							dynamic_cast<CBlock*>(nextBlock)->SetBlockAddCheck(2);

							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx + 1, 1);

							dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
							dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx + 1);
							dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(10, 0));
						}
					}
				}
			}
		}

		else if (m_eKeyDir == KEY_UP)
		{
			if (3 < idx)
			{
				if (tile[idx - 4]->option == 0)
				{
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx - 4, 1);

					dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
					dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx - 4);
					dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(0, -10));
				}

				else if (tile[idx - 4]->option == 1)
				{
					CObj* currBlock = FindBlock(idx);
					CObj* nextBlock = FindBlock(idx - 4);

					if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().value
						== dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().value)
					{
						if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().addCheck == 0
							&& dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().addCheck == 0)
						{
							dynamic_cast<CBlock*>(currBlock)->SetBlockAddCheck(1);
							dynamic_cast<CBlock*>(nextBlock)->SetBlockAddCheck(2);

							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx - 4, 1);

							dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
							dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx - 4);
							dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(0, -10));
						}
					}
				}
			}
		}

		else if (m_eKeyDir == KEY_DOWN)
		{
			if (idx < 12)
			{
				if (tile[idx + 4]->option == 0)
				{
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
					dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx + 4, 1);

					dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
					dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx + 4);
					dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(0, 10));
				}

				else if (tile[idx + 4]->option == 1)
				{
					CObj* currBlock = FindBlock(idx);
					CObj* nextBlock = FindBlock(idx + 4);

					if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().value
						== dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().value)
					{
						if (dynamic_cast<CBlock*>(currBlock)->GetBlockInfo().addCheck == 0
							&& dynamic_cast<CBlock*>(nextBlock)->GetBlockInfo().addCheck == 0)
						{
							dynamic_cast<CBlock*>(currBlock)->SetBlockAddCheck(1);
							dynamic_cast<CBlock*>(nextBlock)->SetBlockAddCheck(2);

							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx, 0);
							dynamic_cast<CBoard*>(m_pBoard)->SetTileOption(idx + 4, 1);

							dynamic_cast<CBlock*>(*p)->SetBlockState(BLOCK_MOVE);
							dynamic_cast<CBlock*>(*p)->SetBlockIndex(idx + 4);
							dynamic_cast<CBlock*>(*p)->SetMovePower(Point2D(0, 10));
						}
					}
				}
			}
		}
	}
}