} // OcclusionIntensity(tex, pos, size) #endregion #region Constructor /// <summary> /// Create base game /// </summary> public BaseGame() { graphics = new GraphicsDeviceManager(this); content = base.Content;//not required: new ContentManager(Services); #if !XBOX360 // Make sure we use the current directory, not the executing directory, // which is not the same for unit tests. // Also include the content directory to make the paths easier and shorter content.RootDirectory = Directory.GetCurrentDirectory(); #endif int resolutionWidth = GameSettings.Default.ResolutionWidth; int resolutionHeight = GameSettings.Default.ResolutionHeight; // Use current desktop resolution if autodetect is selected. if (resolutionWidth <= 0 || resolutionHeight <= 0) { resolutionWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; resolutionHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; } // if (resolutionWidth) #if XBOX360 // Telling the Xbox 360 which resolution we want does not matter graphics.IsFullScreen = true; // Tell the Xbox 360 the resolution anyways, the viewport may just be // 800x600 else! graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; #else graphics.PreferredBackBufferWidth = resolutionWidth; graphics.PreferredBackBufferHeight = resolutionHeight; graphics.IsFullScreen = GameSettings.Default.Fullscreen; #endif //#if DEBUG // Don't limit the framerate to the vertical retrace in debug mode! graphics.SynchronizeWithVerticalRetrace = false; this.IsFixedTimeStep = false; //#endif // Always turn on multisampling, looks much nice, especially on the Xbox360 //does not work nicely together with RenderToTexture: //this.graphics.PreferMultiSampling = true; // Init the space camera camera = new SpaceCamera(this, new Vector3(0, 0, -5)); this.Components.Add(camera); } // BaseGame()
/// <summary> /// Zoom into rocket /// </summary> /// <param name="camera">Camera</param> private void ZoomIntoRocket(SpaceCamera camera, Model rocketModel) { if (Player.GameOver) { // Only start showing rocket after all explosions are nearly over! // Only 400ms left. if (Player.explosionTimeoutMs < 400 && Player.explosionTimeoutMs2 < 400 && Player.explosionTimeoutMs3 < 400) { // Make sure z buffer is on BaseGame.Device.RenderState.DepthBufferEnable = true; // Scale in rocket (cool zoom effect) rocketEndGameScale += BaseGame.MoveFactorPerSecond * 5.0f; if (rocketEndGameScale > 10.0f) rocketEndGameScale = 10.0f; float scale = rocketEndGameScale; // Show rocket in middle of screen. Vector3 inFrontOfCameraPos = new Vector3(0, -0.3f, -1.75f) * 10.0f; inFrontOfCameraPos = Vector3.TransformNormal( inFrontOfCameraPos, BaseGame.InverseViewMatrix); Matrix startMatrix = Matrix.CreateScale(scale, scale, scale) * Matrix.CreateRotationX((float)Math.PI / 2.0f) * Matrix.CreateRotationY(BaseGame.TotalTimeMs / 2293.0f) * Matrix.CreateRotationX(-(float)Math.PI) * Matrix.CreateRotationZ((float)Math.PI / 4.0f) * Matrix.CreateTranslation(inFrontOfCameraPos + BaseGame.CameraPos); rocketModel.Render(startMatrix); // Disable z buffer, now only 2d content is rendered. BaseGame.Device.RenderState.DepthBufferEnable = false; } // if else rocketEndGameScale = 0.0f; } // if }