コード例 #1
0
ファイル: cell.cpp プロジェクト: tkhalymon/chess-old
void Cell::renderSelected(bool check)
{
	renderCell();
	glBegin(GL_QUADS);
	glColor3d(0.3, 0.3, 0.3);
	for (int i = 0; i < 4; ++i)
	{
		glVertex2dv(coords[0 + i].v());
		glVertex2dv(coords[(1 + i) % 4].v());
		glVertex2dv(coords[4 + (1 + i) % 4].v());
		glVertex2dv(coords[4 + i].v());
	}
	glEnd();
	renderPiece(check);
}
コード例 #2
0
ファイル: board.cpp プロジェクト: estan/tetris
void Board::createPiece()
{
	Q_ASSERT(m_piece == 0);

	updateDifficultyFromPerformance();

	m_piece = new Piece(m_next_piece, this);
	if (m_piece->isValid()) {
		m_next_piece = (rand() % 7) + 1;
		emit nextPieceAvailable(renderPiece(m_next_piece));
		m_shift_timer->start();
	} else {
		gameOver();
	}
	update();
	m_isFirstPiece = false;
}
コード例 #3
0
ファイル: cell.cpp プロジェクト: tkhalymon/chess-old
void Cell::renderPointed(bool check)
{
	renderCell();
	glBegin(GL_QUADS);
	for (int i = 0; i < 4; ++i)
	{
		if (color == White) glColor3d(0.5, 0.5, 0.5);
		else glColor3d(0.8, 0.8, 0.8);
		glVertex2dv(coords[0 + i].v());
		glVertex2dv(coords[(1 + i) % 4].v());
		if (color == White) glColor3d(0.8, 0.8, 0.8);
		else glColor3d(0.5, 0.5, 0.5);
		glVertex2dv(coords[4 + (1 + i) % 4].v());
		glVertex2dv(coords[4 + i].v());
	}
	glEnd();
	if (!empty())
	{
		renderPiece(check);
	}
}
コード例 #4
0
ファイル: cubewidget.cpp プロジェクト: Borsos/rubik-6
void CubeWidget::renderCube()
{
	for (int x = -1; x < 2; x++)
	{
		for (int y = -1; y < 2; y++)
		{
			for (int z = -1; z < 2; z++)
			{
				glPushMatrix();

				if (isRotating)
				{
					switch (rotation.type)
					{
						case CubeModel::FRONT:
							if (z == 1)
							{
								if (rotation.cw)
								{
									glRotatef(360.0f - rotationAngle, 0.0f, 0.0f, 1.0f);
								}
								else
								{
									glRotatef(rotationAngle, 0.0f, 0.0f, 1.0f);
								}
							}
							break;
						case CubeModel::BACK:
							if (z == -1)
							{
								if (rotation.cw)
								{
									glRotatef(rotationAngle, 0.0f, 0.0f, 1.0f);
								}
								else
								{
									glRotatef(360.0f - rotationAngle, 0.0f, 0.0f, 1.0f);
								}
							}
							break;
						case CubeModel::UP:
							if (y == 1)
							{
								if (rotation.cw)
								{
									glRotatef(360.0f - rotationAngle, 0.0f, 1.0f, 0.0f);
								}
								else
								{
									glRotatef(rotationAngle, 0.0f, 1.0f, 0.0f);
								}
							}
							break;
						case CubeModel::DOWN:
							if (y == -1)
							{
								if (rotation.cw)
								{
									glRotatef(rotationAngle, 0.0f, 1.0f, 0.0f);
								}
								else
								{
									glRotatef(360.0f - rotationAngle, 0.0f, 1.0f, 0.0f);
								}
							}
							break;
						case CubeModel::LEFT:
							if (x == -1)
							{
								if (rotation.cw)
								{
									glRotatef(rotationAngle, 1.0f, 0.0f, 0.0f);
								}
								else
								{
									glRotatef(360.0f - rotationAngle, 1.0f, 0.0f, 0.0f);
								}
							}
							break;
						case CubeModel::RIGHT:
							if (x == 1)
							{
								if (rotation.cw)
								{
									glRotatef(360.0f - rotationAngle, 1.0f, 0.0f, 0.0f);
								}
								else
								{
									glRotatef(rotationAngle, 1.0f, 0.0f, 0.0f);
								}
							}
							break;
						default:
							break;
					}
				}

				glTranslatef(x * CUBE_SPACING, y * CUBE_SPACING, z * CUBE_SPACING);
				
				renderPiece(x, y, z);

				glPopMatrix();
			}
		}
	}
}