Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            MouseState lastMouse = Mouse.GetState();
            Camera = new Camera(this);
            // side view:
            //Camera.Position = new Vector3(35f, 20f, 0f);
            //Camera.Target = Camera.Position + Vector3.Normalize(new Vector3(7, 4, 0));

            // front view:
            // NOTE: i can't seem to get it looking behind wall1, so we're looking behind wall2
            Camera.Position = new Vector3(0f, 17f, 36f);
            Camera.Target = Camera.Position + Vector3.Normalize(new Vector3(0, 4, 7));

            this.Components.Add(Camera);

            Display = new Display(this);
            Display.DrawOrder = int.MaxValue;
            this.Components.Add(Display);

            DebugDrawer = new DebugDrawer(this);
            this.Components.Add(DebugDrawer);

            primitives[(int)Primitives.box] = new BoxPrimitive(GraphicsDevice);
            primitives[(int)Primitives.capsule] = new CapsulePrimitive(GraphicsDevice);
            primitives[(int)Primitives.cone] = new ConePrimitive(GraphicsDevice);
            primitives[(int)Primitives.cylinder] = new CylinderPrimitive(GraphicsDevice);
            primitives[(int)Primitives.sphere] = new SpherePrimitive(GraphicsDevice);

            BasicEffect = new BasicEffect(GraphicsDevice);
            BasicEffect.EnableDefaultLighting();
            BasicEffect.PreferPerPixelLighting = true;

            base.Initialize();
        }