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


C# RenderWindow.SetFramerateLimit方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            game = new Game();
            game.Start();
            StartupForm startup = new StartupForm();
            DialogResult startupResult;
            do
            {
                startupResult = startup.ShowDialog();
                if (startupResult == DialogResult.Abort)
                {
                    Application.Exit();
                    Environment.Exit(1);
                    return;
                }
            }
            while(startupResult == DialogResult.Cancel);

            app = new RenderWindow(new VideoMode(800, 600), "FTLEdit: Ship Editor", Styles.Default);
            app.Closed += new EventHandler(OnClosed);
            app.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPressed);

            app.SetFramerateLimit(30);

            while (app.IsOpen())
            {
                app.DispatchEvents();
                app.Clear();
                game.Draw(app);
                game.Update();
                app.Display();
                if(game.cursorMode != CursorMode.PlacedBGCursor)
                    Application.DoEvents();
            }
        }
开发者ID:nyteshade,项目名称:FTLEdit,代码行数:35,代码来源:Program.cs

示例2: createDisplay

        public static void createDisplay(bool VSync = false,int FPSCap = 60)
        {
            try
            {
                //Configure the settings of the Window
                ContextSettings settings = new ContextSettings(24, 8, 4, 3, 2);
                window = new RenderWindow(new VideoMode(Convert.ToUInt32(WIDTH), Convert.ToUInt32(HEIGHT)), "OpenGL", Styles.Default, settings);
                Logger.Log(window.Settings.ToString(), Logger.Symbols.Warning);
                if (VSync)
                {
                    window.SetVerticalSyncEnabled(VSync);
                }else
                {
                    window.SetFramerateLimit(Convert.ToUInt32(FPSCap));
                }
                //Setup EventHandler
                window.Closed += new EventHandler(OnClosed);
                window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
                window.Resized += new EventHandler<SizeEventArgs>(OnResized);

                //Init OpenTK
                Toolkit.Init();
                OpenTK.Graphics.GraphicsContext context = new OpenTK.Graphics.GraphicsContext(new ContextHandle(IntPtr.Zero), null);
                GL.Viewport(0, 0, WIDTH, HEIGHT);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.StackTrace);
            }
        }
开发者ID:FelixKimmerle,项目名称:SFMLdotNetOpenGL,代码行数:30,代码来源:DisplayManager.cs

示例3: Initialize

        static void Initialize()
        {
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Environment.CurrentDirectory + "\\libs");
            dtClock = new Stopwatch();
            textFps = new Text("0", new Font(new FileStream("assets\\fonts\\arial.ttf", FileMode.Open, FileAccess.Read)));
            window = new RenderWindow(new VideoMode(1280, 768), "Test", Styles.Default);
            window.SetFramerateLimit(60);
            window.SetTitle("NATE");
            tiles = new TileManager("assets\\tilemaps\\rpgtiles.png", 32);
            iMap = new MapInterface();
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), true); -- for random
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), false); -- blank
            map = iMap.ReadMap("map1.ntm");
            
            scaling = new Vector2f(2, 2);
            textureCollection = new Texture[(tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize)];
            camera = new Camera();
            camera.speed = 1000;

            window.Closed += (s, a) => window.Close();
            window.KeyPressed += (s, a) => { if (a.Code == Keyboard.Key.Z) { iMap.WriteMap("map0.ntm", map); } };
            window.MouseWheelMoved += (s, a) => { scaling.X += a.Delta * 0.075f; scaling.Y += a.Delta * 0.075f; };

            dtClock.Start();

            for (int i = 0; i < (tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize); i++)
            {
                textureCollection[i] = tiles.GetTile(i);
                textureCollection[i].Smooth = false;
            }
        }
开发者ID:leontodd,项目名称:NATE,代码行数:31,代码来源:Program.cs

示例4: Game

 public Game()
 {
     window = new RenderWindow(new VideoMode(800, 600), "LoL");
     window.Closed += (object sender, EventArgs e) => { (sender as Window).Close(); };
     window.SetFramerateLimit(200);
     gTime = new GameTime();
 }
开发者ID:HanHangit,项目名称:2D-Spiel,代码行数:7,代码来源:Game.cs

示例5: Client

        public Client(RenderWindow window, ImageManager imageManager)
            : base(window, imageManager)
        {
            this.window = window;
            world = new RenderImage(800, 600);

            inputManager = new InputManager(this);

            ticker = new Ticker();

            window.ShowMouseCursor (false);
            window.SetFramerateLimit (60);

            NetPeerConfiguration netConfiguration = new NetPeerConfiguration("2dThing");
            client = new NetClient(netConfiguration);

            uMsgBuffer = new UserMessageBuffer();
            otherClients = new Dictionary<int, NetworkClient>();
            chat = new Chat(this);

            LoadRessources();

            blockTypeDisplay = new Cube(blockType, imageManager);
            blockTypeDisplay.Position = new Vector2f(window.Width - 2*Cube.WIDTH, window.Height - 2* Cube.HEIGHT);
            layerDisplay = new LayerDisplay(imageManager);
            layerDisplay.Position = blockTypeDisplay.Position - new Vector2f(0, 50);

            mouse = new Sprite (imageManager.GetImage("mouse"));
        }
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:29,代码来源:Client.cs

示例6: initialise

        public static void initialise()
        {
            window = new RenderWindow(new VideoMode(RESOLUTION_X, RESOLUTION_Y), "Asialaide");

            // Video settings.
            window.SetFramerateLimit(FRAME_LIMIT);
            window.SetVerticalSyncEnabled(VSYNC);
        }
开发者ID:vladivanovic,项目名称:wakarimasen,代码行数:8,代码来源:Drawing.cs

示例7: Main

        public static void Main()
        {
            VideoMode videoMode = VideoMode.DesktopMode;
            videoMode.Width = 800;
            videoMode.Height = 600;
            using (RenderWindow renderWindow = new RenderWindow(videoMode, "SFML Test"))
            {
                renderWindow.SetFramerateLimit(60);

                Game.Window = renderWindow;
                Game.Init();

                renderWindow.Closed += (sender, e) =>
                {
                    renderWindow.Close();
                };

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (renderWindow.IsOpen)
                {
                    renderWindow.DispatchEvents();

                    float dTime = stopwatch.ElapsedMilliseconds / 1000f;
                    stopwatch.Restart();
                    Game.ElapsedTime += dTime;

                    if (false && Game.Entities.OfType<Enemy>().Count() < 3)
                    {
                        Game.Entities.Add(new Enemy(Game.Player)
                        {
                            Position = Vector2.Random(renderWindow.Size.X, renderWindow.Size.Y)
                        });
                    }

                    if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                    {
                        renderWindow.Close();
                    }

                    // Update code goes here
                    foreach (Entity entity in Game.Entities.ToArray())
                    {
                        entity.Update(dTime);
                    }

                    // Rendering code goes here
                    renderWindow.Clear();

                    foreach (Entity entity in Game.Entities.OrderBy(e => e.RenderPriority))
                    {
                        renderWindow.Draw(entity);
                    }
                    renderWindow.Display();
                }
                renderWindow.Close();
            }
        }
开发者ID:Thunder7102,项目名称:RPG,代码行数:58,代码来源:Program.cs

示例8: intialize

 public override void intialize(RenderWindow window)
 {
     base.intialize(window);
     window.SetView(new View(new FloatRect(0, 0, Game1.drawResolution.X, Game1.drawResolution.Y)));
     window.SetFramerateLimit(60);
     window.MouseButtonPressed += window_MouseButtonPressed;
     window.KeyPressed += window_KeyPressed;
     window.Resized += window_Resized;
 }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:9,代码来源:Game1.cs

示例9: Main

        static void Main(string[] args)
        {
            //init stage and input metadata
            stage = new RenderWindow(new VideoMode(800, 640), "WarGames");
            stage.SetFramerateLimit(60);

            //init game and start it
            game = new Game(stage);
            game.start();
        }
开发者ID:Cellmon95,项目名称:Wargames2,代码行数:10,代码来源:Program.cs

示例10: Example

        public Example()
        {
            // Create a TextDisplay to render onto our window
            _example = new TextDisplay(Width, Height);

            // Setup an SFML window
            _window = new RenderWindow(new VideoMode(Width * _example.CharacterWidth, Height * _example.CharacterHeight), "Texter Example", Styles.Close);
            _window.SetFramerateLimit(60);
            _window.Closed += (sender, e) => _window.Close();
        }
开发者ID:Rohansi,项目名称:Texter,代码行数:10,代码来源:Example.cs

示例11: Game

        Game()
        {
            Window = new RenderWindow(new VideoMode(1024u, 768u), "Living Space");

            Window.SetVisible(true);
            Window.SetVerticalSyncEnabled(true);
            Window.SetFramerateLimit(30);

            Window.Closed += OnWindowClosed;
        }
开发者ID:TrueNoob,项目名称:LivingSpace,代码行数:10,代码来源:Game.cs

示例12: Main

        public static void Main(string[] args)
        {
            Window = new RenderWindow(new VideoMode(640, 480), "", Styles.Close);
            Window.SetFramerateLimit(60);

            Window.Closed += (sender, eventArgs) => Window.Close();

            Window.Resized += (sender, eventArgs) =>
            {
                var view = new View();
                view.Size = new Vector2f(eventArgs.Width, eventArgs.Height);
                view.Center = view.Size / 2;
                Window.SetView(view);
            };

            Machine = new VirtualMachine(512 * 1024);

            var prog = File.ReadAllBytes("bios.bin");
            for (var i = 0; i < prog.Length; i++)
                Machine.Memory[i] = prog[i];

            var kbd = new Devices.Keyboard(0x02, Window);
            Machine.Attach(kbd);

            var display = new Devices.Display(0x06, Machine, Window);
            Machine.Attach(display);

            var hdd = new Devices.HardDrive(0x08, "disk.img");
            Machine.Attach(hdd);

            var running = true;

            var stepThread = new Thread(() =>
            {
                while (running)
                {
                    Machine.Step();
                }
            });

            stepThread.Start();

            while (Window.IsOpen())
            {
                Window.DispatchEvents();

                Window.Clear();
                Window.Draw(display);
                Window.Display();
            }

            running = false;
            stepThread.Join();
            Machine.Dispose();
        }
开发者ID:Rohansi,项目名称:LoonyVM,代码行数:55,代码来源:Program.cs

示例13: Initialize

        public void Initialize()
        {
            Window = new RenderWindow(new VideoMode(Screensize.X, Screensize.Y), "Planetary Explorers", Styles.Close | Styles.Titlebar, new ContextSettings(32, 32, 8, 1, 0));

            var spaceMap = new SpaceMap.SpaceMap(new Vector2u(80, 30), new Vector2u(400, 300));

            GM = new GameManager(Window, spaceMap);

            Window.SetFramerateLimit(60);

            Window.Closed += window_Closed;
        }
开发者ID:Sprunth,项目名称:Planetary-Explorers,代码行数:12,代码来源:PEGame.cs

示例14: Game

        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class in debug mode.
        /// </summary>
        /// <param name="path">Path to the project directory.</param>
        /// <param name="x">X co-ordinate of the window</param>
        /// <param name="y">Y co-ordinate of the window</param>
        /// <param name="width">Width of the window</param>
        /// <param name="height">Height of the window</param>
        public Game(string path, uint x, uint y, uint width, uint height)
        {
            if (!ProjectManager.Instance.LoadProject(path)) return;

            RenderWindow = new RenderWindow(new VideoMode(width, height), ProjectManager.Instance.Project.Name);
            RenderWindow.SetFramerateLimit(60);

            if (x != 0 && y != 0)
                RenderWindow.Position = new Vector2i((int)x, (int)y);

            RenderWindow.Closed += OnClose;
        }
开发者ID:GamehubDev,项目名称:Nin_Online_Unity,代码行数:20,代码来源:Game.cs

示例15: SetupWindow

        public void SetupWindow()
        {
            // create window
            _window = new RenderWindow (new VideoMode (1000, 800), "Equation Invasion! - Tainted Mustard", Styles.Close);
            _window.SetVerticalSyncEnabled (true);
            _window.SetFramerateLimit(60);

            // setup SFML event handlers
            _window.Closed += new EventHandler(OnClosed);
            _window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
            _window.KeyReleased += new EventHandler<KeyEventArgs> (OnKeyReleased);
            _window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnMouseClicked);
            _window.TextEntered += new EventHandler<TextEventArgs>(OnTextEntered);
        }
开发者ID:aishsingh,项目名称:EquationInvasion,代码行数:14,代码来源:EquationInvasion.cs


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