コード例 #1
0
ファイル: MainGame.cs プロジェクト: TPDT/TPDT.LogicGraph
        protected override void Initialize(GameConfiguration gameConfiguration)
        {
            base.Initialize(gameConfiguration);            // Initialize a TextFormat

            Components.Add(ScreenManager = new ScreenManager(this));
            ScreenManager.ToggleScreen(new GameScreen(this));

            // Initialize a TextFormat
            TextFormat = new TextFormat(FactoryDWrite, "微软雅黑", 128) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center };

            RenderTarget2D.TextAntialiasMode = TextAntialiasMode.Cleartype;

            // Initialize a TextLayout
            TextLayout = new TextLayout(FactoryDWrite, "编程棋 Alpha 0", TextFormat, gameConfiguration.Width, gameConfiguration.Height);

        }
コード例 #2
0
ファイル: Game2DBase.cs プロジェクト: TPDT/TPDT.LogicGraph
        protected override void Initialize(GameConfiguration demoConfiguration)
        {
            Factory2D = new SharpDX.Direct2D1.Factory();
            FactoryDWrite = new SharpDX.DirectWrite.Factory();

            HwndRenderTargetProperties properties = new HwndRenderTargetProperties();
            properties.Hwnd = DisplayHandle;
            properties.PixelSize = new SharpDX.Size2(demoConfiguration.Width, demoConfiguration.Height);
            properties.PresentOptions = PresentOptions.None;

            RenderTarget2D = new WindowRenderTarget(Factory2D, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)), properties);

            RenderTarget2D.AntialiasMode = AntialiasMode.PerPrimitive;


            SceneColorBrush = new SolidColorBrush(RenderTarget2D, Color.White);
        }
コード例 #3
0
ファイル: GameApp.cs プロジェクト: TPDT/TPDT.LogicGraph
        /// <summary>
        /// Runs the demo.
        /// </summary>
        public void Run(GameConfiguration demoConfiguration)
        {
            _demoConfiguration = demoConfiguration ?? new GameConfiguration();
            _form = CreateForm(_demoConfiguration);
            Components = new GameComponentCollection();
            Initialize(_demoConfiguration);

            bool isFormClosed = false;
            bool formIsResizing = false;

            _form.MouseClick += HandleMouseClick;
            _form.KeyDown += HandleKeyDown;
            _form.KeyUp += HandleKeyUp;
            _form.Resize += (o, args) =>
            {
                if (_form.WindowState != _currentFormWindowState)
                {
                    HandleResize(o, args);
                }

                _currentFormWindowState = _form.WindowState;
            };

            _form.ResizeBegin += (o, args) => { formIsResizing = true; };
            _form.ResizeEnd += (o, args) =>
            {
                formIsResizing = false;
                HandleResize(o, args);
            };

            _form.Closed += (o, args) => { isFormClosed = true; };

            LoadContent();

            clock.Start();
            BeginRun();
            RenderLoop.Run(_form, () =>
            {
                if (isFormClosed)
                {
                    return;
                }

                OnUpdate();
                if (!formIsResizing)
                    Render();
            });

            UnloadContent();
            EndRun();

            // Dispose explicity
            Dispose();
        }
コード例 #4
0
ファイル: GameApp.cs プロジェクト: TPDT/TPDT.LogicGraph
 /// <summary>
 ///   In a derived class, implements logic to initialize the sample.
 /// </summary>
 protected abstract void Initialize(GameConfiguration demoConfiguration);
コード例 #5
0
ファイル: GameApp.cs プロジェクト: TPDT/TPDT.LogicGraph
 /// <summary>
 /// Create Form for this demo.
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 protected virtual Form CreateForm(GameConfiguration config)
 {
     return new RenderForm(config.Title)
     {
         ClientSize = new System.Drawing.Size(config.Width, config.Height)
     };
 }