Пример #1
0
void GLWidget::sceneTimerEvent()
{
	int moveCount= movingCount();

	if(moveCount==1) {
		// 0 1 2 3
		if(movingTo[0]) camera.move(0);
		if(movingTo[1]) camera.move(90);
		if(movingTo[2]) camera.move(180);
		if(movingTo[3]) camera.move(270);
	} else {
		// Diagonals
		if(movingTo[0] && movingTo[1]) camera.move(45);
		if(movingTo[1] && movingTo[2]) camera.move(135);
		if(movingTo[2] && movingTo[3]) camera.move(225);
		if(movingTo[3] && movingTo[0]) camera.move(315);
	}

	// The camera changed position
	if(moveCount) movedWhileGrabbed= true;

	// Only updateGL when needed
	//update();
	paintGL();
}
Пример #2
0
// ================================ test code ================================
void test(char* testName, int threshold, int rows, int cols, int expected)
{
    if(testName != NULL)
        printf("%s begins: ", testName);
    
    if(movingCount(threshold, rows, cols) == expected)
        printf("Passed.\n");
    else
        printf("FAILED.\n");
}