# PendulumGame.PendulumGravityChooserScreen Class Reference

This screen implements gravity chooser for the Pendulum Game. More...

Inheritance diagram for PendulumGame.PendulumGravityChooserScreen:

List of all members.

## Public Member Functions
| PendulumGravityChooserScreen ()
| Constructor of the screen.
override void | LoadContent ()
| Load graphics content for the game.
override void | UnloadContent ()
| Unload graphics content used by the game.
override void | Update (GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
| Updates the state of the game. This method checks the GameScreen.IsActive property, so the game will stop updating when the pause menu is active, or if you tab away to a different application.
override void | HandleInput (InputState input)
| Lets the game respond to player input. Unlike the Update method, this will only be called when the gameplay screen is active.
override void | Draw (GameTime gameTime)
| Draws the gameplay screen.

## Detailed Description

This screen implements gravity chooser for the Pendulum Game.

Definition at line 23 of file PendulumGravityChooserScreen.cs.

## Constructor & Destructor Documentation

PendulumGame.PendulumGravityChooserScreen.PendulumGravityChooserScreen | ( |  | ) |

Constructor of the screen.

Definition at line 79 of file PendulumGravityChooserScreen.cs.

    00080         {
    00081             TransitionOnTime = TimeSpan.FromSeconds(1.5);
    00082             TransitionOffTime = TimeSpan.FromSeconds(1.5);
    00083
    00084             this.zoom = false;
    00085         }

## Member Function Documentation

override void PendulumGame.PendulumGravityChooserScreen.Draw | ( | GameTime | gameTime | ) | `[virtual]`

Draws the gameplay screen.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 285 of file PendulumGravityChooserScreen.cs.

    00286         {
    00287             // Match transition to selector size
    00288             if (this.zoom)
    00289             {
    00290                 gravitySelector.DisplaySize = 1.0f + TransitionPosition;
    00291             }
    00292             else
    00293             {
    00294                 gravitySelector.DisplaySize = 1.0f - TransitionPosition;
    00295             }
    00296
    00297             // Draw gravity selector
    00298             gravitySelector.Draw(gameTime);
    00299
    00300             // If the game is transitioning on or off, fade it out to black.
    00301             if (TransitionPosition > 0)
    00302             {
    00303                 ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
    00304             }
    00305         }

override void PendulumGame.PendulumGravityChooserScreen.HandleInput | ( | InputState | input | ) | `[virtual]`

Lets the game respond to player input. Unlike the Update method, this will only be called when the gameplay screen is active.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 207 of file PendulumGravityChooserScreen.cs.

    00208         {
    00209             if (input == null)
    00210             {
    00211                 throw new ArgumentNullException("input");
    00212             }
    00213
    00214             if (input.IsInputCancel(null) || input.IsDisconnected(null))
    00215             {
    00216                 ScreenManager.AddScreen(new PendulumPauseMenuScreen(), null);
    00217             }
    00218             else
    00219             {
    00220                 if (input.IsInputSelect(null))
    00221                 {
    00222                     // Capture selected value
    00223                     PendulumGame.State.CurrentGravity = gravitySelector.Gravity;
    00224                     this.zoom = true;
    00225
    00226                     // Quit to options menu
    00227                     PendulumLoadingScreen.Load(
    00228                         ScreenManager,
    00229                         true,
    00230                         null,
    00231                         new PendulumGameplayScreen());
    00232                 }
    00233
    00234                 // Keyboard speed adjustment
    00235                 if (input.IsInputLeft(null))
    00236                 {
    00237                     longitudeSpeed += speedStep;
    00238                 }
    00239                 else if (input.IsInputRight(null))
    00240                 {
    00241                     longitudeSpeed -= speedStep;
    00242                 }
    00243
    00244                 if (input.IsInputUp(null))
    00245                 {
    00246                     latitudeSpeed += speedStep;
    00247                 }
    00248                 else if (input.IsInputDown(null))
    00249                 {
    00250                     latitudeSpeed -= speedStep;
    00251                 }
    00252
    00253                 // Speed limiter
    00254                 if (longitudeSpeed < -speedMax)
    00255                 {
    00256                     longitudeSpeed = -speedMax;
    00257                 }
    00258                 else if (longitudeSpeed > speedMax)
    00259                 {
    00260                     longitudeSpeed = speedMax;
    00261                 }
    00262
    00263                 if (latitudeSpeed < -speedMax)
    00264                 {
    00265                     latitudeSpeed = -speedMax;
    00266                 }
    00267                 else if (latitudeSpeed > speedMax)
    00268                 {
    00269                     latitudeSpeed = speedMax;
    00270                 }
    00271
    00272                 // Update rotation
    00273                 gravitySelector.Longitude += longitudeSpeed;
    00274                 gravitySelector.Latitude += latitudeSpeed;
    00275
    00276                 // Drag speed
    00277                 longitudeSpeed *= speedDragFactor;
    00278                 latitudeSpeed *= speedDragFactor;
    00279             }
    00280         }

override void PendulumGame.PendulumGravityChooserScreen.LoadContent | ( |  | ) | `[virtual]`

Load graphics content for the game.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 90 of file PendulumGravityChooserScreen.cs.

    00091         {
    00092             if (this.contentManager == null)
    00093             {
    00094                 this.contentManager = new ContentManager(ScreenManager.Game.Services, "Content");
    00095             }
    00096
    00097             // Create physical element(s)
    00098             GravityCalculator gravityCalculator =
    00099                 new GravityCalculator(PendulumGame.State.CurrentCelestialObject);
    00100
    00101             // Per-object settings and sound
    00102             this.cue = null;
    00103             switch (PendulumGame.State.CurrentCelestialObject)
    00104             {
    00105                 case CelestialObject.Earth:
    00106                     gravityCalculator.EarthGravityModel =
    00107                         PendulumGame.State.CurrentEarthGravityModel;
    00108                     this.cue = this.ScreenManager.SoundBank.GetCue("earth");
    00109                     break;
    00110                 case CelestialObject.Mars:
    00111                     gravityCalculator.MarsGravityModel =
    00112                         PendulumGame.State.CurrentMarsGravityModel;
    00113                     break;
    00114                 case CelestialObject.Sun:
    00115                     this.cue = this.ScreenManager.SoundBank.GetCue("sun");
    00116                     break;
    00117                 case CelestialObject.Venus:
    00118                     this.cue = this.ScreenManager.SoundBank.GetCue("venus");
    00119                     break;
    00120                 case CelestialObject.Jupiter:
    00121                     this.cue = this.ScreenManager.SoundBank.GetCue("jupiter");
    00122                     break;
    00123                 case CelestialObject.Callisto:
    00124                     this.cue = this.ScreenManager.SoundBank.GetCue("callisto");
    00125                     break;
    00126                 case CelestialObject.Ganymede:
    00127                     this.cue = this.ScreenManager.SoundBank.GetCue("ganymede");
    00128                     break;
    00129                 case CelestialObject.Europa:
    00130                     this.cue = this.ScreenManager.SoundBank.GetCue("europa");
    00131                     break;
    00132                 case CelestialObject.Saturn:
    00133                     this.cue = this.ScreenManager.SoundBank.GetCue("saturn");
    00134                     break;
    00135             }
    00136
    00137             this.gravitySelector = new GravitySelector(
    00138                 ScreenManager,
    00139                 PendulumGame.State.CurrentCelestialObject,
    00140                 gravityCalculator);
    00141
    00142             // Lower volume of sound
    00143             this.ScreenManager.SetVolume("Default", 1.0f);
    00144
    00145             // Start sound
    00146             if (null != this.cue)
    00147             {
    00148                 this.cue.Play();
    00149             }
    00150
    00151             // Reset game time
    00152             ScreenManager.Game.ResetElapsedTime();
    00153         }

override void PendulumGame.PendulumGravityChooserScreen.UnloadContent | ( |  | ) | `[virtual]`

Unload graphics content used by the game.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 158 of file PendulumGravityChooserScreen.cs.

    00159         {
    00160             if (null != this.cue)
    00161             {
    00162                 this.cue.Stop(AudioStopOptions.Immediate);
    00163             }
    00164
    00165             this.contentManager.Unload();
    00166         }

override void PendulumGame.PendulumGravityChooserScreen.Update | ( | GameTime | gameTime,
|  | bool | otherScreenHasFocus,
|  | bool | coveredByOtherScreen |
| ) |  |  | `[virtual]`

Updates the state of the game. This method checks the GameScreen.IsActive property, so the game will stop updating when the pause menu is active, or if you tab away to a different application.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 177 of file PendulumGravityChooserScreen.cs.

    00179         {
    00180             base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
    00181
    00182             if (IsActive)
    00183             {
    00184                 // Maybe start sound
    00185                 if ((null != this.cue) && (!this.cue.IsPlaying))
    00186                 {
    00187                     this.cue.Resume();
    00188                 }
    00189
    00190                 // Animate gravity selector
    00191                 gravitySelector.Update(gameTime);
    00192             }
    00193             else
    00194             {
    00195                 // Maybe stop sound
    00196                 if ((null != this.cue) && (this.cue.IsPlaying))
    00197                 {
    00198                     this.cue.Pause();
    00199                 }
    00200             }
    00201         }

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/PendulumGame/Screens/PendulumGravityChooserScreen.cs