示例#1
0
文件: Main.cpp 项目: joe90p/TetrisCpp
void Initialise()
{
	dbSetDisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,32);
	dbSetImageColorKey(255,0,255);
	
	// Turn on fullscreen mode
	dbSetWindowLayout(0, 0, 1);
	dbMaximizeWindow();
	// turn on sync rate and set maximum rate to 60 fps
	dbSyncOn   ( );
	dbSyncRate ( 60 );
	
	dbDrawSpritesFirst();
	
	//seed randomness
	srand ( time(NULL) );
}
示例#2
0
文件: Main.cpp 项目: njt1982/BiPlane
// the main entry point for the application is this function
void DarkGDK ( void ){
	// Seed the random number generator
	srand(time(NULL));

	// Configure the engine to run as fast as possible (no frame rate cap)
	dbSyncOn();
	dbSyncRate(0);

	// If fullscreen, configure to a, currently, hard coded setting
	if (FULLSCREEN) {
		dbSetWindowOff();
		dbMaximizeWindow();
		dbSetDisplayModeAntialias(1680, 1050, 32, 1, 0, 0);
		dbSetCameraAspect(0, 1680.0 / 1050.0);
	}
	// Otherwise, configure a windowed display
	else {
		dbSetDisplayModeAntialias(1280, 800, 32, 1, 0, 0);
		dbSetCameraAspect(0, 1280.0 / 800.0);

		int winPosX = (dbDesktopWidth() - dbScreenWidth()) / 2;
		int winPosY = (dbDesktopHeight() - dbScreenHeight()) / 2;

		dbSetWindowPosition(winPosX, winPosY);
	}
	
	// Hide the mouse pointer; CEGUI handles this
	dbHideMouse();

	// This forces the timer to initialise
	MyTimer *timer = &MyTimer::get();
	float t;


	// Create a new Game State - this is a general game controlling class
	BiPlaneGameState *gsGame = new BiPlaneGameState();

	// We'll need a start-up menu	
	StartMenuGameState *gsMenu = new StartMenuGameState();
	
	// a Loop State holder
	bool loopState = TRUE;

	// This is for the Start Menu loop
	//while (LoopGDK()) {
	do {
		// Tick the timer & frame rate for this loop
		timer->tick();
		t = timer->getT();
		dbText(0, 0, dbStr((float)(1.0 / t)));

		loopState &= gsGame->update(t);
		loopState &= gsMenu->update(t);

		dbSync();
	} while (loopState && LoopGDK());
	


	switch (gsMenu->getState()) {
		// Start Server
		case 1 :
			break;

		// Start Client
		case 2 :
			break;

		// SOMETHING WENT WRONG!!
		default : exit(-5);
	}


	loopState = TRUE;
	// our main loop
	//while (LoopGDK()) {
	do {
		// Tick the timer & frame rate for this loop
		timer->tick();
		t = timer->getT();
		dbText(0, 0, dbStr((float)(1.0 / t)));

		// Issue an Update to the GameState system, passing the frameTime into it
		loopState &= gsGame->update(t);

		// Update the display
		dbSync();
	} while (loopState && LoopGDK());

	// Do a little house keeping
	delete gsGame;
	delete gsMenu;
	return;
}