//players = 1 or 2 //sections = 1,2 or 3 (small, medium, long) ---> has scaling factor. default set to 6 //difficulty = 1, 2, or 3 (easy, medium, hard) public GameLayer(int players, int numSections, int difficulty) : base() { cooloffBlue = 2000; cooloffGreen = 2000; // Screen layer attributes numPlayers = players; numSectionScalingFactor = 6; isTransparent = false; transitionOnTime = TimeSpan.FromSeconds(0.6); transitionOffTime = TimeSpan.FromSeconds(0.5); // 3D view vars viewport = Globals.graphics.GraphicsDevice.Viewport; // drawable layers canvas = new SpriteBatch(Globals.graphics.GraphicsDevice); game3DLayer = new RenderTarget2D( Globals.graphics.GraphicsDevice, viewport.Width, viewport.Height, false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents); // Create the renderer, this renderer binds to the graphics device and with the given width and height, is used to // draw everything on each frame renderer = new Renderer(Globals.graphics.GraphicsDevice, Globals.content, viewport.Width, viewport.Height); // The light and mesh container is used to store mesh and light obejcts. This is just for RENDERING. Not for DRAWING sceneGraph = new BlockBasedSceneGraph(numSections * numSectionScalingFactor); sceneGraph.SetSubMeshDelegate(delegate(Mesh.SubMesh subMesh) { renderer.SetupSubMesh(subMesh); subMesh.RenderEffect.AmbientParameter.SetValue(Vector4.Zero); }); sceneGraph.SetLightDelegate(delegate(Light l) { }); // Load the Game //second number is number of players Globals.gameInstance = new RealGame(numSections * numSectionScalingFactor, numPlayers, sceneGraph); cameraController = new CameraController(viewport, Matrix.Identity); cameraController.Fit(Globals.gameInstance.GetCriticalPoints()); cameraController.MoveToTarget(); }
//construct public MenuBackground() { viewport = Globals.graphics.GraphicsDevice.Viewport; // Create the renderer, this renderer binds to the graphics device and with the given width and height, is used to // draw everything on each frame renderer = new Renderer(Globals.graphics.GraphicsDevice, Globals.content, viewport.Width, viewport.Height); // The light and mesh container is used to store mesh and light obejcts. This is just for RENDERING. Not for DRAWING lightAndMeshContainer = new SimpleSceneGraph(); lightAndMeshContainer.SetSubMeshDelegate(delegate(Mesh.SubMesh subMesh) { renderer.SetupSubMesh(subMesh); subMesh.RenderEffect.AmbientParameter.SetValue(Vector4.Zero); }); lightAndMeshContainer.SetLightDelegate(delegate(Light l) { }); camera = new Camera(); camera.Aspect = viewport.AspectRatio; camera.NearClip = 0.1f; camera.FarClip = 1000; camera.Viewport = viewport; camera.Transform = Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(170),-0.3f,0) * Matrix.CreateTranslation(2,5f,-4); Mesh m = new Mesh(); m.Model = AssetLoader.mdl_menuscene; m.Transform = Matrix.Identity; lightAndMeshContainer.AddMesh(m); Light mainlight = new Light(); mainlight.LightType = Light.Type.Spot; mainlight.Color = Color.AntiqueWhite; mainlight.Transform = Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(170),-0.7f,0) * Matrix.CreateTranslation(0, 5f, -4); mainlight.SpotAngle = 50; mainlight.SpotExponent = 1; mainlight.Radius = 13; mainlight.Intensity = 2f; lightAndMeshContainer.AddLight(mainlight); }