///Function that starts the entire process.
void ScreenSaver::execute(int& argc , char** argv) {

	///Generating objects
	generateTable();
	generateBall();
	

	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(WIDTH , HEIGHT);
	glutInitWindowPosition(50,50);
	windowID = glutCreateWindow(" Bouncy ball ");

	init();
	threadInit();
	initSkybox();

	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMouseFunc(handleMouse);
	glutKeyboardFunc(handleKeyboard);
	glutSpecialFunc(handleSpecial); 
	//GLUI *glUserInterface = GLUI_Master.create_glui_subwindow( windowID,GLUI_SUBWINDOW_RIGHT );
	menu.createMenu();	

	glutTimerFunc(DELTA_T , timer , 0);
	glutMainLoop();
	for(int i=0; i<NUM_BALLS;i++)
		pthread_exit(&vecBallThread[i]);
}
Esempio n. 2
0
void RandomPolygonMenu::update( float dt ){
	world->update( dt );
	Menu::update( dt );

	if( isChanged() ){
		generateTable();
	}
}
Esempio n. 3
0
void TrackFour::load()
{
	generateTable();
	lprintf("Track object created with following parameters: %d %d\n",BOUNDARY_CELL_SIZE * 3,numCellsY);
	lprintf("Track numCellsX numCellsY = %d %d\n",numCellsX,numCellsY);

	loadImage(1);
}
Esempio n. 4
0
RandomDistribution::RandomDistribution(const std::vector<double>& weights) 
{
	randomSeed(m_seed); // initialize prng
	m_weights = weights;
	m_probs.resize(m_weights.size());
	m_alias.resize(m_weights.size());
	generateTable();
}
Esempio n. 5
0
	GameTable::GameTable(int height, int width)
	{
		srand(time(NULL));
		_height = height;
		_width = width;
		generateTable();
		makeMove(1, 1);
		generateCoins();
		_map[0][0] = 4;
		_map[1][0] = 0;
		_map[_width - 1][_height - 2] = 2;
	}
Esempio n. 6
0
static WORD table_setXformSpec (
    IP_XFORM_HANDLE hXform,         /* in: handle for xform */
    DWORD_OR_PVOID  aXformInfo[])   /* in: xform information */
{
    PTBL_INST g;

    HANDLE_TO_PTR (hXform, g);

    if (! generateTable(g,aXformInfo))
        goto fatal_error;
    return IP_DONE;

    fatal_error:
    return IP_FATAL_ERROR;
}
Esempio n. 7
0
int main ( int argc, char* argv[] ) { //PFC编码、解码算法统一测试入口
   /*DSA*/if ( 2 > argc ) { printf ( "Usage: %s <message#1> [message#2] ...\a\n", argv[0] ); return -1; }
   PFCForest* forest = initForest(); //初始化PFC森林
   PFCTree* tree = generateTree ( forest ); release ( forest ); //生成PFC编码树
   /*DSA*/print ( tree );
   PFCTable* table = generateTable ( tree ); //将PFC编码树转换为编码表
   /*DSA*/for ( int i = 0; i < N_CHAR; i++ ) printf ( " %c: %s\n", i + 0x20, * ( table->get ( i + 0x20 ) ) ); //输出编码表
   for ( int i = 1; i < argc; i++ ) { //对于命令行传入的每一明文串
      /*DSA*/printf ( "\nEncoding: %s\n", argv[i] ); //开始编码
      Bitmap codeString; //二进制编码串
      int n = encode ( table, codeString, argv[i] ); //将根据编码表生成(长度为n)
      /*DSA*/printf ( "%s\n", codeString.bits2string ( n ) ); //输出当前文本的编码串
      /*DSA*/printf ( "Decoding: " ); //开始解码
      decode ( tree, codeString, n ); //利用编码树,对长度为n的二进制编码串解码(直接输出)
   }
   release ( table ); release ( tree ); return 0; //释放编码表、编码树
}
Esempio n. 8
0
void showScene( int argc, char* argv[] )
{
	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB );
	glutInitWindowSize( 800,800/*1200, 675*/ );
	glutCreateWindow( "SceneGraph" );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glutSwapBuffers();

	glPolygonMode(GL_FRONT,GL_FILL);

	generateScene();
	generateTable();

	glutDisplayFunc( redrawScene );
	glutMainLoop();
}
/******************************************************************************************
 * 无论编码森林由列表、完全堆还是左式堆实现,本测试过程都可适用
 * 编码森林的实现方式采用优先级队列时,编译前对应的工程只需设置相应标志:
 *    DSA_PQ_List、DSA_PQ_ComplHeap或DSA_PQ_LeftHeap
 ******************************************************************************************/
int main(int argc, char* argv[]) { //Huffman编码算法统一测试
   /*DSA*/if (3 > argc) { printf("Usage: %s <sample-text-file> <message#1> [message#2] ...\a\n", argv[0]); return -1; }
   int* freq = statistics(argv[1]); //根据样本文件,统计各字符的出现频率
   HuffForest* forest = initForest(freq); release(freq); //创建Huffman森林
   HuffTree* tree = generateTree(forest); release(forest); //生成Huffman编码树
   /*DSA*/print(tree); //输出编码树
   HuffTable* table = generateTable(tree); //将Huffman编码树转换为编码表
   /*DSA*/for (int i = 0; i < N_CHAR; i++) //输出编码表
      /*DSA*/printf(" %c: %s\n", i+0x20, *(table->get(i+0x20)));
   for (int i = 2; i < argc; i++) { //对于命令行传入的每一明文串
      /*DSA*/printf("\nEncoding: %s\n", argv[i]);
      Bitmap* codeString = new Bitmap; //二进制编码串将通过
      int n = encode(table, codeString, argv[i]); //调用编码算法生成(总长为n)
      /*DSA*/printf("%s\n", codeString->bits2string(n)); //输出编码串
      /*DSA*/printf("Decoding: ");
      decode(tree, codeString, n); //利用Huffman编码树,对长度为n的二进制编码串解码
      release(codeString);
   }
   release(table); release(tree); return 0; //释放编码表、编码树
}
Esempio n. 10
0
RandomPolygonMenu::RandomPolygonMenu( App* app ) : Menu( app ){
	seedSlider = new SliderComponent( vec2(200, 20), this );
	polygonSidesSlider = new SliderComponent( vec2(200, 40), this );
	polygonPointsSlider = new SliderComponent( vec2(200, 60), this );
	polygonNumTriesSlider = new SliderComponent( vec2(200, 80), this );
	polygonScaleSlider = new SliderComponent( vec2(200, 100), this );
	polygonHolesSlider = new SliderComponent( vec2(200, 120), this );

	seedLabel = new LabelComponent( "0", vec2(260, 16), this );
	polygonSidesLabel = new LabelComponent( "5", vec2(260, 36), this );
	polygonPointsLabel = new LabelComponent( "5", vec2(260, 56), this );
	polygonNumTriesLabel = new LabelComponent( "10", vec2(260, 76), this );
	polygonScaleLabel = new LabelComponent( "8", vec2(260, 96), this );
	polygonHolesLabel = new LabelComponent( "0", vec2(260, 116), this );

	polygonTypeCheckbox = new CheckboxComponent( {"Smooth random polygon", "Random polygon"}, vec2(320, 20), this );
	polygonTypeCheckbox->setSelected( 0 );

	startButton = new ButtonComponent( "START", vec2( 650, 50), [=](){
		srand( seedSlider->getPercent() * RAND_MAX );
		app->setWorld( new GameWorld( cueTable ) );
		app->setMenu( 0 );
	}, this );

	errorLabel = new LabelComponent( "", vec2(320,90), this );

	world = new RandomTableWorld();

	addComponent( new LabelComponent( "Seed:", vec2(50, 16), this ) );
	addComponent( new LabelComponent( "Sides:", vec2(50, 36), this ) );
	addComponent( new LabelComponent( "Points", vec2(50, 56), this ) );
	addComponent( new LabelComponent( "NumTries:", vec2(50, 76), this ) );
	addComponent( new LabelComponent( "Scale:", vec2(50, 96), this ) );
	addComponent( new LabelComponent( "Holes:", vec2(50, 116), this ) );

	addComponent( seedSlider );
	addComponent( polygonSidesSlider );
	addComponent( polygonPointsSlider );
	addComponent( polygonNumTriesSlider );
	addComponent( polygonScaleSlider );
	addComponent( polygonHolesSlider );

	addComponent( seedLabel );
	addComponent( polygonSidesLabel );
	addComponent( polygonPointsLabel );
	addComponent( polygonNumTriesLabel );
	addComponent( polygonScaleLabel );
	addComponent( polygonHolesLabel );

	addComponent( polygonTypeCheckbox );
	addComponent( startButton );
	addComponent( errorLabel );

	seedSlider->setValue( 0 );
	polygonSidesSlider->setValue( 0 );
	polygonPointsSlider->setValue( 0 );
	polygonNumTriesSlider->setValue( 0 );
	polygonScaleSlider->setValue( 0 );
	polygonHolesSlider->setValue( 0 );

	generateTable();
}
Esempio n. 11
0
void TrackFour::generateTable()
{
	int i,j;
	int leftStripCount, rightStripCount;

	height = STAGE_FOUR_HEIGHT;

	//Make sure to reflect the numCellsX and numCellsY to correspond to current stage
	numCellsX = 25;
	numCellsY = (getHeight() / BOUNDARY_CELL_SIZE);
	numTurns = TRACK_FOUR_TURNS - 1;

	generateTable(trackInfoLeft, trackInfoRight, 106, 8);

	int roadWidth = trackInfoLeft[0].roadWidth;
	char bigRow[25];

	leftStripCount = 0;
	rightStripCount = 0;

	for(i = numCellsY - 1; i >= 0 ; i--)
	{
		for(j = 0; j < roadWidth; j++)
		{
			if(j == 0)
			{
				bigRow[j] = TRACKFOUR_BOUNL;
			}
			else if(j == roadWidth - 1)
			{
				bigRow[j] = TRACKFOUR_BOUNR;
			}
			else if(j == 2)
			{
				if(leftStripCount < 3)
				{
					bigRow[j] = TRACKFOUR_STRIP;
					leftStripCount++;
				}
				else if(leftStripCount > 2 && leftStripCount < 5)
				{
					bigRow[j] = TRACKFOUR_ROAD;
					leftStripCount++;
				}
				else
					leftStripCount = 0;
			}
			else if(j == 5)
			{
				if(rightStripCount < 3)
				{
					bigRow[j] = TRACKFOUR_STRIP;
					rightStripCount++;
				}
				else if(rightStripCount > 2 && rightStripCount < 5)
				{
					bigRow[j] = TRACKFOUR_ROAD;
					rightStripCount++;
				}
				else
					rightStripCount = 0;
			}
			else
				bigRow[j] = TRACKFOUR_ROAD;
		}
		memcpy(cellArray[i], bigRow, roadWidth);
	}

	//paste finish line
	cellArray[VP->getNumCellsY() - 6][2] = TRACKFOUR_FINISH;
	cellArray[VP->getNumCellsY() - 6][3] = TRACKFOUR_FINISH;
	cellArray[VP->getNumCellsY() - 6][4] = TRACKFOUR_FINISH;
	cellArray[VP->getNumCellsY() - 6][5] = TRACKFOUR_FINISH;
	cellArray[VP->getNumCellsY() - 6][6] = TRACKFOUR_FINISH;
}
Esempio n. 12
0
/** Launch program by generating table. */
int main (int argc, char **argv) {
  generateTable();
  exit (0);
}
Esempio n. 13
0
void TrackThree::generateTable()
{
	int i,j;
	int count;

	height = STAGE_THREE_HEIGHT;

	//Make sure to reflect the numCellsX and numCellsY to correspond to current stage
	numCellsX = 25;
	numCellsY = (getHeight() / BOUNDARY_CELL_SIZE);
	numTurns = TRACK_THREE_TURNS - 1;

	generateTable(trackInfoLeft, trackInfoRight, 73, 8);

	int roadWidth = trackInfoLeft[0].roadWidth;
	char bigRow[25];

	count = 0;

	for(i = numCellsY - 1; i >= 0 ; i--)
	{
		for(j = 0; j < roadWidth; j++)
		{
			if(j == 0)
			{
				bigRow[j] = TRACKTHREE_BOUNL;
			}
			else if(j == roadWidth - 1)
			{
				bigRow[j] = TRACKTHREE_BOUNR;
			}
			else if(j == roadWidth / 2)
			{
				if(count < 3)
				{
					if(guardRail[i].showRoadStrip)
					{
						bigRow[j] = TRACKTHREE_STRIP;
					}
					else
					{
						bigRow[j] = TRACKTHREE_ROAD;
					}
					count++;
				}
				else if(count > 2 && count < 5)
				{
					bigRow[j] = TRACKTHREE_ROAD;
					count++;
				}
				else
					count = 0;
			}
			else
				bigRow[j] = TRACKTHREE_ROAD;
		}
		memcpy(cellArray[i], bigRow, roadWidth);
	}

	//paste finish line
	cellArray[VP->getNumCellsY() - 6][1] = TRACKTHREE_FINISH;
	cellArray[VP->getNumCellsY() - 6][2] = TRACKTHREE_FINISH;
	cellArray[VP->getNumCellsY() - 6][3] = TRACKTHREE_FINISH;
	cellArray[VP->getNumCellsY() - 6][4] = TRACKTHREE_FINISH;
}