CPitchMeter mcPitchMeter; // The Pitch Meter // Class constructor public CShootingGallery(AxWMPLib.AxWindowsMediaPlayer cWindowsMediaPlayer) { try { // Pre-load images mcTargetFacingLeftImage = Image.FromFile("../../Data/Images/ShootingGalleryDuckFacingLeft.png"); mcTargetFacingRightImage = Image.FromFile("../../Data/Images/ShootingGalleryDuckFacingRight.png"); // Pre-load sounds } catch (Exception e) { MessageBox.Show(e.ToString(), "Exception caught"); } // Seed the Random number generator mcRandom = new Random(Environment.TickCount); // Save a handle to the Windows Media Player mcWindowsMediaPlayer = cWindowsMediaPlayer; // Set the Transparent Color of the Images mcTargetImageAttributes = new ImageAttributes(); mcTargetImageAttributes.SetColorKey(Color.FromArgb(255, 0, 255), Color.FromArgb(255, 0, 255)); // Setup the Fonts mcFontText = new Font("Arial", 20, FontStyle.Regular); mcFontPause = new Font("Arial", 120, FontStyle.Regular); mcFontChooseMusicTitle = new Font("Arial", 40, FontStyle.Bold); // Set the Row Y coordinates miTOP_ROW_Y = 75; miMIDDLE_ROW_Y = 210; miBOTTOM_ROW_Y = 350; // Set the Shoot Target Area Range miSHOOT_TARGET_AREA_LEFT = 375; miSHOOT_TARGET_AREA_RIGHT = 426; miSHOOT_TARGET_AREA_TOP = 75; miSHOOT_TARGET_AREA_BOTTOM = 450; // Specify the Center X pixel of the screen miCENTER_OF_SCREEN_X = 398; // Initialize the Pitch Meter mcPitchMeter = new CPitchMeter(miSHOOT_TARGET_AREA_LEFT + 22, miSHOOT_TARGET_AREA_TOP, 5, (miSHOOT_TARGET_AREA_BOTTOM - miSHOOT_TARGET_AREA_TOP)); mcPitchMeter.ShowThirdsMarkers(true); // Set the Mario Music parameters mcSIMPLE_MUSIC = new CMusic(EMusic.Simple, 1, 52, 55); mcDANS_MARIO_MUSIC = new CMusic(EMusic.DansMario, 1, 76, 78); mcMARIO_MUSIC = new CMusic(EMusic.Mario, 1, 54, 59); // Set the Players Score to zero miScore = 0; // Set the other variables default values Reset(); }
// Function loads the currently Highlighted song and starts the game private void StartPlayingWithCurrentlyHightlightedSong() { FileInfo cMidiFileInfo; // Use the Highlighted Song as the Song to Use switch (meHighlightedMusic) { default: case EMusic.Simple: // Set the Music to Play mcCurrentMusic = mcSIMPLE_MUSIC; // Store the Path of the Music to play cMidiFileInfo = new FileInfo("../../Data/Music/Simple.mid"); break; case EMusic.DansMario: // Set the Music to Play mcCurrentMusic = mcDANS_MARIO_MUSIC; // Store the Path of the Music to play cMidiFileInfo = new FileInfo("../../Data/Music/DansMario.mid"); break; case EMusic.Mario: // Set the Music to Play mcCurrentMusic = mcMARIO_MUSIC; // Store the Path of the Music to play cMidiFileInfo = new FileInfo("../../Data/Music/Mario.mid"); break; } // Reset the Players Score to zero miScore = 0; // Start Playing the Music mcWindowsMediaPlayer.URL = cMidiFileInfo.FullName; mcWindowsMediaPlayer.Ctlcontrols.play(); // Start Playing the Game meShootingGalleryState = EShootingGalleryGameStates.Play; }
// Reset class variables to their default values public void Reset() { // Record that we are playing Pong meGame = EGames.ShootingGallery; // Set the games initial State meShootingGalleryState = EShootingGalleryGameStates.ChoosingSong; // Set the default Music to use meHighlightedMusic = EMusic.Mario; mcCurrentMusic = mcMARIO_MUSIC; // Stop any Music that might be playing mcWindowsMediaPlayer.Ctlcontrols.stop(); // Reset the duration the Song has been done playing for mfSecondsSongHasBeenCompleteFor = 0.0f; // Create the Target List mcTargetList = new List <CTarget>(); }