当前位置: 首页>>代码示例>>C#>>正文


C# Keyboard.IsKeyDown方法代码示例

本文整理汇总了C#中Keyboard.IsKeyDown方法的典型用法代码示例。如果您正苦于以下问题:C# Keyboard.IsKeyDown方法的具体用法?C# Keyboard.IsKeyDown怎么用?C# Keyboard.IsKeyDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Keyboard的用法示例。


在下文中一共展示了Keyboard.IsKeyDown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override void Run()
        {
            window = new Window(1280, 720); // Create a window with the resolution 1280x720.
            renderer = new Renderer(window, false); // Create our renderer using our window, enabling vsync.
            renderer.ClearColor = new Color3(12, 12, 12); // Set our clear color to an almost black color.

            k = window.Keyboard;

            Texture t = new Texture("Resources/Untitled.png", TextureFilter.Nearest, true);

            ourShader = new ShaderTest4(); // Create our shader.
            ourShader.Texture = t;
            xxxx = new ShaderTest4();
            // ourShader.Texture = Texture.Default;
            //cube = new Cube(ourShader); // Create our cube using our shader.
            cube = new Mesh(RenderTextureMesh.RenderTextureVertices, RenderTextureMesh.RenderTextureTextureCoordinates, new float[0],
                RenderTextureMesh.RenderTextureIndices, ourShader);
            xxxxddddd = new Mesh(Cube.CubeVertices, Cube.CubeTextureCoordinates, new float[0],
                Cube.CubeIndices, ourShader);
            sprite = new Sprite(200, 200, t);
            sprite.X = 0;
            sprite.Y = 200;
            sprite.Width = 400;

            renderer.Camera.Position = new Vector3(2, 2, 2); // Set our camera position to 2, 2, 2 (XYZ)
            renderer.Camera.Pitch = Angle.CreateDegrees(35); // Set our camera's pitch.
            renderer.Camera.Yaw = Angle.CreateDegrees(315); // Set our camera's yaw.

            //Text x = new Text("DUNAMIS", new Font("DINRg.ttf"), 24, false, false, false, Color4.White, true, 0, 0);
            //  x.String = "HELLO";

            testere = new Text("DUNAMIS hello", new Font("Resources/DINRg.ttf"));
            testere.Color = Color4.White;
            testere.Size = 54;

            while (true)
            {
                cube.Yaw += 0.0005f;
                renderer.Clear(); // Clear the screen.

                renderer.Draw(cube); // Draw our cube.
                renderer.Draw(xxxxddddd); // TODO: fix texture not switching to empty
                renderer.Draw(sprite);
                // renderer.Draw(x);
                renderer.Draw(testere);

                renderer.Display(); // Display the result.
                window.Update(); // Update window events.

                if (k.IsKeyDown(Key.Z))
                {
                    renderer.Camera.FieldOfView -= 0.05f;
                }
                if (k.IsKeyDown(Key.X))
                {
                    renderer.Camera.FieldOfView += 0.05f;
                }
                if (k.IsKeyDown(Key.A))
                {
                    renderer.Camera.Yaw -= 0.0005f;
                }
                if (k.IsKeyDown(Key.D))
                {
                    renderer.Camera.Yaw += 0.0005f;
                }
                if (k.IsKeyDown(Key.W))
                {
                    renderer.Camera.Pitch -= 0.0005f;
                }
                if (k.IsKeyDown(Key.S))
                {
                    renderer.Camera.Pitch += 0.0005f;
                }
            }
        }
开发者ID:killowatt,项目名称:Dunamis,代码行数:75,代码来源:CubeExample.cs


注:本文中的Keyboard.IsKeyDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。