// Reset class variables to their default values public void Reset() { // Record that we are playing Pong meGame = EGames.Spong; // Set the games initial State mePongState = EPongGameStates.Pause; // Record that the game hasn't started yet mbGameStarted = false; // Set the Paddles initial position mrPaddle = new Rectangle(80, 250, 20, 100); // Set the Balls initial position, direction, and speed mrBall = new Rectangle(150, 250, 20, 20); mcBallDirection = new Vector2(1.0f, 0.0f); mcBallDirection.Normalize(); mcBallDirection.Scale(miBALL_START_SPEED); // Initial speed ResetBall(); // Start the player with no Score and 3 Lives miScore = 0; miLives = 3; // Set the initial Pitch Meter Indicators position mcPitchMeter.UpdatePitchIndicatorsPosition(0.5f); }
// Function to Move the Arrow to be on the Bow private void MoveArrowToBow() { mrArrow.X = mrBOW_AND_ARROW_POSITION.X; mrArrow.Y = mrBOW_AND_ARROW_POSITION.Y + 40; // Reset the Bow orientation mcPitchMeter.UpdatePitchIndicatorsPosition(0.0f); }
// Reset class variables to their default values public void Reset() { // Record that we are playing Pong meGame = EGames.PitchMatcher; // Set the games initial State mePitchMatcherState = EPitchMatcherGameStates.Pause; // Record that the Game hasn't started yet mbGameStarted = false; // Set the initial game Duration mfGameTimeRemaining = miGAME_DURATION; // Reset the Pitch To Match variables mfTimeBeforeChangingTargetPitchInSeconds = 0.0f; mfUnitTargetPitchToAchieve = 0.0f; mfTargetPitchChangeVelocity = 0.0f; mfCurrentUnitTargetPitch = 0.5f; // Set the initial Pitch Meter Indicator positions mcPitchMeter.UpdatePitchIndicatorsPosition(0.5f); mcPitchMeterToMatch.UpdatePitchIndicatorsPosition(0.5f); }
FMOD.Sound msSoundFire = null; // Sound when the player Fires the Arrow // Class constructor public CTargetPractice() { try { // Pre-load images mcBowAndArrowImage = Image.FromFile("../../Data/Images/TargetPracticeBowAndArrow.png"); mcArrowImage = Image.FromFile("../../Data/Images/TargetPracticeArrow.png"); mcTargetImage = Image.FromFile("../../Data/Images/TargetPracticeTarget.png"); // Pre-load sounds CFMOD.CheckResult(CFMOD.GetSystem().createSound("../../Data/Sounds/TargetPracticeHit.wav", FMOD.MODE.DEFAULT, ref msSoundHit), "FMOD Create Sound Error"); CFMOD.CheckResult(CFMOD.GetSystem().createSound("../../Data/Sounds/TargetPracticeMiss.wav", FMOD.MODE.DEFAULT, ref msSoundMiss), "FMOD Create Sound Error"); CFMOD.CheckResult(CFMOD.GetSystem().createSound("../../Data/Sounds/TargetPracticeFire.wav", FMOD.MODE.DEFAULT, ref msSoundFire), "FMOD Create Sound Error"); } catch (Exception e) { MessageBox.Show(e.ToString(), "Exception caught"); } // Seed the Random number generator mcRandom = new Random(Environment.TickCount); // Setup the Pitch Meter mcPitchMeter = new CPitchMeter(500, 125); mcPitchMeter.ShowFourthsMarkers(true); // Setup the Fonts mcFontText = new Font("Arial", 20, FontStyle.Regular); mcFontLarge = new Font("Arial", 50, FontStyle.Regular); // Start the player with no Score miScore = 0; // Record that we are playing Pong meGame = EGames.TargetPractice; // Set the games initial State meTargetPracticeState = ETargetPracticeGameStates.Aiming; // Set the initial Pitch Meter Indicator positions mcPitchMeter.UpdatePitchIndicatorsPosition(0.0f); // Initialize the constants mcGRAVITY_ACCELERATION = new Vector2(0.0f, 65.0f); mrBOW_AND_ARROW_POSITION = new Rectangle(10, 400, 60, 69); // Specify the initial Target and Arrow positions mrTarget = new Rectangle(650, 250, 128, 128); mrArrow = new RectangleF(10, 10, 60, 11); MoveTargetToNewRandomLocation(); MoveArrowToBow(); // Set the Arrows initial Velocity and the initial Power mcArrowVelocity = new Vector2(); mfUnitBowAndArrowPower = 0.0f; // Set the initial Bow And Arrow and Arrow Rotations miBowAndArrowRotation = miArrowRotation = 0; // Initialize the Reset Arrow Wait Time mfResetArrowWaitTime = 0.0f; // Initialize the Arrow Hit Target variable mbArrowHitTarget = false; }