示例#1
0
        protected override void Initialize()
        {
            player = new Player(this, new Vector3(0, 2, 0));
            player.Initialize();

            // New camera code
            camera = new FirstPersonCamera(graphics.GraphicsDevice,
                                           new ViewMatrixSettings(new Vector3(0, 5, 0), Vector3.Up, Vector3.Forward));

            IsMouseVisible = true;
            Mouse.SetPosition(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2);

            terrain = new Terrain();

            Random random = new Random();

            for (int x = -20; x < 20; x++)
            {
                for (int z = -20; z < 20; z++)
                {
                    terrain.AddBlockAt(new IntPoint3D(x, -1, z), GraphicsDevice);

                    if (random.Next(3) == 0)
                    {
                        terrain.AddBlockAt(new IntPoint3D(x, 0, z), GraphicsDevice);
                    }
                }
            }

            base.Initialize();
        }