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


C# RenderWindow.Close方法代码示例

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


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

示例1: 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

示例2: Main

        static int Main(string[] args)
        {
            // The Screen or Window
            VideoMode videoMode = new VideoMode(1024, 768);
            RenderWindow window = new RenderWindow(videoMode,
                "Learn SFML");
            window.Closed += new EventHandler(window_Closed);
            window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(window_MouseButtonPressed);
            window.MouseMoved += new EventHandler<MouseMoveEventArgs>(window_MouseMoved);
            window.KeyPressed += new EventHandler<KeyEventArgs>(window_KeyPressed);

            Start();

            Console.Out.WriteLine("Engine Started Successfully!");

            while (window.IsOpen()
                && !quit)
            {
                window.DispatchEvents();

                // Draw
                currentScreen.Draw(window);
                window.Display();
            }
            window.Close();

            return 0;
        }
开发者ID:MrPhil,项目名称:LD24,代码行数:28,代码来源:Program.cs

示例3: Game

        public Game(uint width = 1365, uint height = 768)
        {
            if (!File.Exists(IniFileName))
            {
                MessageBox.Show(string.Format("Brak pliku {0}!", IniFileName));
                Environment.Exit(1);
            }

            ReadIniFile(IniFileName);

            Players = new Dictionary<int, PlayerInstance>();

            Width = width;
            Height = height;

            var settings = new ContextSettings { AntialiasingLevel = 8 };
            Window = new RenderWindow(new VideoMode(Width, Height), "Nano War", Styles.Close, settings);

            Window.Closed += (s, a) =>
                {
                    GameClient.GameClient.Dispose();
                    Window.Close();
                };
            Window.SetVerticalSyncEnabled(true);
            Window.SetKeyRepeatEnabled(false);

            StateMachine = new StateMachine();
            AudioManager = new AudioManager();
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:29,代码来源:Game.cs

示例4: Main

        public static void Main(string[] args)
        {
            var win = new RenderWindow(new VideoMode(800, 600), "Some Crappy Zombie Thing");
            win.Closed += (sender, e) => win.Close ();
            var curtime = DateTime.Now;
            double dt = 0;
            double frametime;
            win.SetVisible (true);
            EntityManager.Add (new RectangleTestEntity(true));
            EntityManager.Add (new DebugInfo());
            EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", 0, 1));
            EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", "45down", new Vector2f(35, 40), 1));
            Entity ent = new Entity();
            ent.OnDraw += (sender, e) => e.Surface.Draw (new Text("Loooooonnnnggg Teeeexxxttt") {Position = new Vector2f(700, 500)});
            EntityManager.Add (ent);
            EntityManager.InitializeWindow (win);

            while(win.IsOpen ())
            {
                win.DispatchEvents();
                EntityManager.Draw (win);
                win.Display ();
                frametime = (DateTime.Now-curtime).TotalMilliseconds;
                dt += frametime;
                while (dt >= EntityManager.TimeStep)
                {
                    //Console.WriteLine (dt.ToString ());
                    EntityManager.Update (dt, frametime);
                    dt -= EntityManager.TimeStep;
                }
                curtime = DateTime.Now;
            }
        }
开发者ID:Phyxius,项目名称:SomeZombieGame,代码行数:33,代码来源:Main.cs

示例5: 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

示例6: Main

        static void Main(string[] args)
        {
            var videoMode = new VideoMode(1000, 700);
            var contextSettings = new ContextSettings(0, 0, 4);
            RenderWindow window = new RenderWindow(videoMode, "Luda Diaria", Styles.Default, contextSettings);
            window.SetActive(true);
            window.Closed += (sender, e) => window.Close();
            Global.Window = window;

            Randomizer.Generator = new Random(42);

            var input = InputManager.Instance;
            input.Init();

            StateManager.Instance.CurrentState = new LoadingState();

            var lastTick = DateTime.Now;
            const float maxTimeStep = 0.5f;

            while (window.IsOpen())
            {
                float dt = (float)((DateTime.Now - lastTick).TotalSeconds);
                lastTick = DateTime.Now;

                window.DispatchEvents();
                window.Clear(Color.Black);

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

                while (dt > 0)
                {
                    //---UPDATE
                    var deltatTime = dt < maxTimeStep ? dt : maxTimeStep;
                    StateManager.Instance.CurrentState.Update(deltatTime);
                    dt -= maxTimeStep;
                }
                //---DRAW

                StateManager.Instance.CurrentState.Draw(window, RenderStates.Default);
                window.Display();
            }
        }
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:45,代码来源:Program.cs

示例7: 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

示例8: 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

示例9: Run

        public void Run()
        {
            TextureLoader.Init();

            Window = new RenderWindow(videoMode, title, Styles.Close);
            States = new RenderStates(RenderStates.Default);

            Window.Closed += (s, e) =>
            {
                Console.WriteLine("Closing...");
                Window.Close();
            };

            Window.SetVerticalSyncEnabled(true);

            defaultView = Window.DefaultView;
            gameView = Window.DefaultView;
            gameView.Viewport = new FloatRect(0, 0, .85f, .85f);

            BackgroundColor = new Color(100, 149, 237); // dat cornflower blue
            Tilemap = new Tilemap(this);

            SelectedTileID = 1;

            var timer = new Stopwatch();
            while (Window.IsOpen)
            {
                timer.Restart();

                Window.DispatchEvents();

                var mouse = Mouse.GetPosition(Window);

                //if (Mouse.IsButtonPressed(Mouse.Button.Right))
                //    gameView.Move(new Vector2f(prevMouse.X - mouse.X, prevMouse.Y - mouse.Y));

                Tilemap.Update(Frametime);

                Window.Clear(BackgroundColor);

                Window.SetView(gameView);
                Tilemap.Draw(Window, States);
                Window.SetView(defaultView);

                Debug.Draw(Window);

                Window.Display();

                prevMouse = mouse;

                timer.Stop();
                Frametime = (float)timer.Elapsed.TotalMilliseconds;
                Window.SetTitle($"{title} ({(1d / timer.Elapsed.TotalSeconds):0}fps)");
            }
        }
开发者ID:Spanfile,项目名称:LD33,代码行数:55,代码来源:Game.cs

示例10: Loop

        public static void Loop()
        {
            gameWindow = new RenderWindow(new VideoMode(WindowWidth, WindowHeight), WindowTitle);
            gameWindow.Closed += (sender, args) => gameWindow.Close();

            while (gameWindow.IsOpen()) {
                gameWindow.DispatchEvents();
                gameWindow.Clear();

                starfield.Draw(ref gameWindow);
                player.Draw(ref gameWindow);

                gameWindow.Display();
            }
        }
开发者ID:AdamMOD,项目名称:Space-Game,代码行数:15,代码来源:Game.cs

示例11: Main

        public static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "Titan");
            GameWorld game = new GameWorld();

            game.createWorld();
            window.Closed += (sender, eventArgs) => window.Close();
            window.SetFramerateLimit(60);

            while (window.IsOpen())
            {
                window.DispatchEvents();
                game.update(window);
                game.render(window);
                window.Display();
            }
        }
开发者ID:Jamsterx1,项目名称:Titan,代码行数:17,代码来源:Program.cs

示例12: Main

        static void Main(string[] args)
        {
            Window = new RenderWindow(new VideoMode(1280, 720), "Collapse");
            Window.SetFramerateLimit(60);
            Window.Closed += (sender, eventArgs) => Window.Close();

            Map = new TileMap(200, 90);
            for (var y = 85; y < 100; y++)
            {
                for (var x = 0; x < 200; x++)
                {
                    Map[x, y] = Tile.Floor;
                }
            }

            Window.MouseMoved += (sender, eventArgs) =>
            {
                var mousePosF = Window.MapPixelToCoords(new Vector2i(eventArgs.X, eventArgs.Y));
                var mousePos = new Vector2i((int)mousePosF.X / TileSize, (int)mousePosF.Y / TileSize);

                if (Mouse.IsButtonPressed(Mouse.Button.Left))
                {
                    Map[mousePos.X, mousePos.Y] = Tile.Block;
                }

                if (Mouse.IsButtonPressed(Mouse.Button.Right))
                {
                    Map[mousePos.X, mousePos.Y] = Tile.None;
                }

                if (Mouse.IsButtonPressed(Mouse.Button.Middle))
                {
                    Map[mousePos.X, mousePos.Y] = Tile.Floor;
                }
            };

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

                Window.Clear(new Color(100, 149, 237));
                Window.Draw(Map);
                Window.Display();
            }
        }
开发者ID:Rohansi,项目名称:Collapse,代码行数:45,代码来源:Program.cs

示例13: Main

        public static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "SFML Window");
            window.Closed += (sender, eventArgs) => window.Close();

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

                // TODO: Insert Update Code Here

                window.Clear(CornflowerBlue);

                // TODO: Insert Draw Code Here

                window.Display();
            }
        }
开发者ID:phillium,项目名称:LazarHockey,代码行数:18,代码来源:Program.cs

示例14: Initialize

        public static void Initialize()
        {
            var style = Styles.Titlebar | Styles.Close;
            if (GameOptions.Resizable)
                style |= Styles.Resize;

            size = new Vector2f(GameOptions.Width, GameOptions.Height);

            Window = new RenderWindow(new VideoMode(GameOptions.Width, GameOptions.Height), GameOptions.Caption, style);
            Window.SetFramerateLimit(GameOptions.Framerate);
            Window.SetVerticalSyncEnabled(GameOptions.Vsync);

            if (GameOptions.Icon != "")
            {
                Texture texture = Assets.LoadTexture(GameOptions.Icon);
                Window.SetIcon(texture.Size.X, texture.Size.Y, texture.CopyToImage().Pixels);
            }

            Window.Closed += (sender, args) => Window.Close();
            Window.Resized += (sender, args) => Resize(new Vector2f(args.Width, args.Height));
            Window.MouseButtonPressed += (sender, args) => DispatchEvent(new MouseButtonInputArgs(args.Button, true, args.X, args.Y));
            Window.MouseButtonReleased += (sender, args) => DispatchEvent(new MouseButtonInputArgs(args.Button, false, args.X, args.Y));
            Window.MouseWheelMoved += (sender, args) => DispatchEvent(new MouseWheelInputArgs(args.Delta, args.X, args.Y));
            Window.MouseMoved += (sender, args) => DispatchEvent(new MouseMoveInputArgs(args.X, args.Y));
            Window.TextEntered += (sender, args) => DispatchEvent(new TextInputArgs(args.Unicode));

            Window.KeyPressed += (sender, args) =>
            {
                if (args.Code == Keyboard.Key.Unknown || keyStates[(int)args.Code]) // repeated key press
                    return;
                keyStates[(int)args.Code] = true;
                DispatchEvent(new KeyInputArgs(args.Code, true, args.Control, args.Shift));
            };

            Window.KeyReleased += (sender, args) =>
            {
                if (args.Code != Keyboard.Key.Unknown)
                    keyStates[(int)args.Code] = false;
                DispatchEvent(new KeyInputArgs(args.Code, false, args.Control, args.Shift));
            };
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:41,代码来源:Game.cs

示例15: KeyPressedActions

		/// <summary>
		/// The list of actions performed for a key pressed
		/// </summary>
		public static void KeyPressedActions(RenderWindow window, KeyEventArgs keyPressed)
		{
			switch (keyPressed.Code)
			{
				case Keyboard.Key.Escape:
					window.Close();
					break;

				case Keyboard.Key.Delete:
					/*You can insert actions here for that particular case*/
					break;

				case Keyboard.Key.A:
					/*You can insert actions here for that particular case*/
					break;

				/*Etc...*/

				default:
					break;
			}
		}
开发者ID:RSF-Deus,项目名称:SFML.Net-V2.2-Template,代码行数:25,代码来源:KeyboardEventHandler.cs


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