Exemplo n.º 1
0
void Init(HWND hWnd)
{
    // Set our global window handle to our main window
    g_hWnd = hWnd;

    // Create our double buffering our window
    g_Buffer.CreateDoubleBuffering(hWnd);

    // This is where we create the image of our character
    HBITMAP hPlayerImage = g_Buffer.LoadABitmap((LPSTR)kPlayerImage);

    // Initialize our player with it's image and position
    g_Player.Init(hPlayerImage, kPlayerStartX, kPlayerStartY);

    // Init, load and draw the first map file
    g_Map.Load(kStartMap);
    g_Map.SetDrawFlag(true);

    // Here we load then play the starting background music
    if(!g_Music.Init("techno.mod"))
        exit(0);

    g_Music.PlaySong();

    // we need to seed our random number generator (rand()) for moving npcs.
    srand(GetTickCount());

    // Set the backbuffer to black first (This clears the backbuffer)
    g_Buffer.ClearScreen(BLACK_BRUSH);
}
int main()									// Beginning of our program
{	
	CFmod mySong;							// Create our class

	if(!mySong.Init(SONG_NAME))				// Init our CFmod class AND load the song
		exit(1);						    // If an error is occurred, we immediately
											// exit the program

	// We not have the Fmod Sound System initialized and we also have the song loaded.
	// All we need to do now is play the song.

	// Now we will play the current song loaded (SONG_NAME)
	mySong.PlaySong();

	// Here we post a message that tells how to quit the program
	cout << "Press any key to quit" << endl;
	cout << "=========================================================================\n";

	// Now that the song is playing, we want to get some information about it.
	// Below we print out the amount of channels being played and the CPU usage.  
	// The CPU Usage is displayed in a percentage.  The "channels playing" should
	// only say one, since we only have one sound going.  There are more channels
	// when dealing with MOD and MIDI music because it isn't one constant flow of
	// sound data, it is a mixing of data.

	// Loop until we hit the keyboard
	while (!_kbhit())
	{
		// Print out the details of the current song being played.
		// Notice the "\r", it will redraw over itself each time.
		cout << " channels playing: " << FSOUND_GetChannelsPlaying() // This returns the amount of channels being played
			 << " cpu usage: "<< FSOUND_GetCPUUsage()	// This returns the CPU usage we are taking up
			 << "%     \r";				
	} 

	// We get here if we hit a key on the keyboard, so that must mean we are done.
	// Now we need to do the clean up.  We don't need to clean up because the
	// DeConstructor does it for us.
		
	// Wait for a key to be pressed before we quit
	getch();

	// Go the the next line
	cout << endl;

	// Return a success!
    return 0;
}