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


C# RenderWindow.SetTitle方法代码示例

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


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

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

示例2: ViewPort

        public ViewPort(ViewPortCollection parent, Screen screen, int id, bool isFullScreen)
        {
            ID = id;
            Parent = parent;

            Styles style;

            if (isFullScreen)
            {
                style = Styles.Fullscreen;
                WorkingArea = new Rectangle(
                    screen.Bounds.X,
                    screen.Bounds.Y,
                    screen.Bounds.Width, // - 1
                    screen.Bounds.Height); // - 1
            } else {
                style = Styles.Resize;
                WorkingArea = new Rectangle(
                        screen.WorkingArea.Left,
                        screen.WorkingArea.Top,
                        (int)(screen.WorkingArea.Width * 0.5),
                        (int)(screen.WorkingArea.Height * 0.5)
                    );
            }

            Window = new RenderWindow(
                new VideoMode(
                    (uint)WorkingArea.Width,
                    (uint)WorkingArea.Height
                ),
                "Screensaver [debug]",
                style,
                new ContextSettings(32, 0, 0)
                );

            Window.Position = new Vector2i(WorkingArea.Left, WorkingArea.Top);
            Window.SetTitle(Window.Position.X + "," + Window.Position.Y);
        }
开发者ID:nathanchere,项目名称:MatrixSaver,代码行数:38,代码来源:ViewPort.cs

示例3: Run

        public void Run()
        {
            GameHelper.SetGame(this);

            Window = new RenderWindow(mode, title, Styles.Close);
            RStates = new RenderStates(RenderStates.Default);

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

            Window.SetVerticalSyncEnabled(true);

            BackgroundColor = new Color(100, 149, 237);

            World = new World.World(this);

            World.AddObject(new Box(this, new Vector2f(50, 50), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(300, 200), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(450, 350), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(100, 250), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(200, 150), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(150, 400), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(400, 100), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(500, 250), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(600, 300), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(350, 450), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(650, 500), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(400, 100), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(250, 350), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(400, 100), new Vector2f(64, 64), Color.White));
            World.AddObject(new Box(this, new Vector2f(650, 50), new Vector2f(64, 64), Color.White));

            Lighting = new Lighting(this);
            var light = new PointLight(this, new Vector2f(100, 10), Color.Blue, 100f, 32);

            Lighting.AddLight(light);

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

                Window.DispatchEvents();

                Window.Clear(BackgroundColor);

                World.Update(Frametime);
                Lighting.Update(Frametime);

                light.Position = new Vector2f(Mouse.GetPosition(Window).X, Mouse.GetPosition(Window).Y);

                World.Draw(Window, RStates);
                Lighting.Draw(Window, RStates);

                Debug.Draw(Window);

                Window.Display();

                timer.Stop();
                Frametime = (float)timer.Elapsed.TotalMilliseconds;
                Window.SetTitle($"{title} ({Math.Round(Frametime, 1):0.0}ms)");
            }
        }
开发者ID:snowfox0x,项目名称:2D-Lighting-Sample,代码行数:66,代码来源:Game.cs

示例4: Main

        static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                Console.WriteLine("No game loaded into memory.");
                return;
            }
            else
            {
                Console.WriteLine(" -Chocolate Chip8-");
                Console.WriteLine(" An emulator for the 'Chip8' computer system.");
                Console.WriteLine(" Programmed by Ethan Green");
                Console.WriteLine(" https://github.com/metherul/ChocolateChip");

                Emulator em = new Emulator();

                string FILELOAD = args[0];
                em.LoadROM(FILELOAD);

                RenderWindow window = new RenderWindow(new VideoMode(900, 600), "Chocolate Chip8");
                window.Closed += new EventHandler(window_Closed);

                float TILESIZEX = (float)window.Size.X / em.Screen.GetLength(0);
                float TILESIZEY = (float)window.Size.Y / em.Screen.GetLength(1);
                RectangleShape shape = new RectangleShape(new Vector2f(TILESIZEX, TILESIZEY));
                window.SetFramerateLimit(60);
                window.SetTitle(" Chocolate Chip8 | Ethan Green");
                while (window.IsOpen())
                {
                    bool changescreen = em.Step();
                    //Console.WriteLine(changescreen);
                    if (changescreen)
                    {
                        window.DispatchEvents();

                        //window.Clear();

                        for (int x = 0; x < em.Screen.GetLength(0); x++)
                        {
                            for (int y = 0; y < em.Screen.GetLength(1); y++)
                            {
                                shape.Position = new Vector2f(x * TILESIZEX, y * TILESIZEY);
                                if (em.Screen[x, y] != 0)
                                {
                                    shape.FillColor = new Color(255, 255, 255);
                                }
                                else
                                {
                                    shape.FillColor = new Color(0, 0, 0);
                                }
                                window.Draw(shape);
                            }
                        }

                        em.SendInput(0, Keyboard.IsKeyPressed(Keyboard.Key.Num0));
                        em.SendInput(1, Keyboard.IsKeyPressed(Keyboard.Key.Num2));
                        em.SendInput(2, Keyboard.IsKeyPressed(Keyboard.Key.Num3));
                        em.SendInput(3, Keyboard.IsKeyPressed(Keyboard.Key.Num4));
                        em.SendInput(4, Keyboard.IsKeyPressed(Keyboard.Key.Q));
                        em.SendInput(5, Keyboard.IsKeyPressed(Keyboard.Key.W));
                        em.SendInput(6, Keyboard.IsKeyPressed(Keyboard.Key.E));
                        em.SendInput(7, Keyboard.IsKeyPressed(Keyboard.Key.R));
                        em.SendInput(8, Keyboard.IsKeyPressed(Keyboard.Key.A));
                        em.SendInput(9, Keyboard.IsKeyPressed(Keyboard.Key.S));
                        em.SendInput(10, Keyboard.IsKeyPressed(Keyboard.Key.D));
                        em.SendInput(11, Keyboard.IsKeyPressed(Keyboard.Key.F));
                        em.SendInput(12, Keyboard.IsKeyPressed(Keyboard.Key.Z));
                        em.SendInput(13, Keyboard.IsKeyPressed(Keyboard.Key.X));
                        em.SendInput(14, Keyboard.IsKeyPressed(Keyboard.Key.C));
                        em.SendInput(15, Keyboard.IsKeyPressed(Keyboard.Key.V));

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

示例5: Start

        public void Start()
        {
            Console.WriteLine("Starting...");

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

            Window.SetVerticalSyncEnabled(true);

            Window.Closed += Window_Closed;
            Window.GainedFocus += (s, e) => Focused = true;
            Window.LostFocus += (s, e) => Focused = false;

            RStates = new RenderStates(RenderStates.Default);

            GameWorld = new World(this);
            GameWorld.AddActor(new Player(this, "keyconfig.cfg"));

            var frametimer = new System.Diagnostics.Stopwatch();
            while (Window.IsOpen())
            {
                frametimer.Restart();

                Window.DispatchEvents();

                GameWorld.Update(Frametime);

                Window.Clear(Color.Transparent);

                GameWorld.Draw(Window, RStates);

                Window.Display();

                frametimer.Stop();
                Frametime = (float)frametimer.Elapsed.TotalMilliseconds;
                FPS = 1f / (float)frametimer.Elapsed.TotalSeconds;
                Window.SetTitle(String.Format("{0} (FPS {1})", title, Math.Floor(FPS + 0.5f)));
            }
        }
开发者ID:ilezhnin,项目名称:Roguelike-like-like,代码行数:38,代码来源:Game.cs

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

示例7: Main

        static void Main(string[] args)
        {
            //args = new string[1] { "c8games/TICTAC" };
            if (args.Length <= 0)
            {
                Console.WriteLine("No game dragged into exe");
                return;
            }
            else
            {
                Emulator em = new Emulator();
                //Console.WriteLine(args[0]);
                string FILELOAD = args[0];
                em.LoadROM(FILELOAD);

                RenderWindow window = new RenderWindow(new VideoMode(900, 600), "Chip8.net");
                window.Closed += new EventHandler(window_Closed);

                float TILESIZEX = (float)window.Size.X / em.Screen.GetLength(0);
                float TILESIZEY = (float)window.Size.Y / em.Screen.GetLength(1);
                RectangleShape shape = new RectangleShape(new Vector2f(TILESIZEX, TILESIZEY));
                window.SetFramerateLimit(60);
                window.SetTitle("Chip8.net PLAYING: " + FILELOAD);
                while (window.IsOpen())
                {
                    bool changescreen = em.Step();
                    //Console.WriteLine(changescreen);
                    if (changescreen)
                    {
                        window.DispatchEvents();

                        //window.Clear();

                        for (int x = 0; x < em.Screen.GetLength(0); x++)
                        {
                            for (int y = 0; y < em.Screen.GetLength(1); y++)
                            {
                                shape.Position = new Vector2f(x * TILESIZEX, y * TILESIZEY);
                                if (em.Screen[x, y] != 0)
                                {
                                    shape.FillColor = new Color(255, 255, 255);
                                }
                                else
                                {
                                    shape.FillColor = new Color(100, 100, 100);
                                }
                                window.Draw(shape);
                            }
                        }

                        em.SendInput(0, Keyboard.IsKeyPressed(Keyboard.Key.Num0));
                        em.SendInput(1, Keyboard.IsKeyPressed(Keyboard.Key.Num2));
                        em.SendInput(2, Keyboard.IsKeyPressed(Keyboard.Key.Num3));
                        em.SendInput(3, Keyboard.IsKeyPressed(Keyboard.Key.Num4));
                        em.SendInput(4, Keyboard.IsKeyPressed(Keyboard.Key.Q));
                        em.SendInput(5, Keyboard.IsKeyPressed(Keyboard.Key.W));
                        em.SendInput(6, Keyboard.IsKeyPressed(Keyboard.Key.E));
                        em.SendInput(7, Keyboard.IsKeyPressed(Keyboard.Key.R));
                        em.SendInput(8, Keyboard.IsKeyPressed(Keyboard.Key.A));
                        em.SendInput(9, Keyboard.IsKeyPressed(Keyboard.Key.S));
                        em.SendInput(10, Keyboard.IsKeyPressed(Keyboard.Key.D));
                        em.SendInput(11, Keyboard.IsKeyPressed(Keyboard.Key.F));
                        em.SendInput(12, Keyboard.IsKeyPressed(Keyboard.Key.Z));
                        em.SendInput(13, Keyboard.IsKeyPressed(Keyboard.Key.X));
                        em.SendInput(14, Keyboard.IsKeyPressed(Keyboard.Key.C));
                        em.SendInput(15, Keyboard.IsKeyPressed(Keyboard.Key.V));

                        window.Display();
                    }
                }
            }
        }
开发者ID:Austech,项目名称:Chip8-CSharp,代码行数:72,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {
            v0 = 50;
            Random locationInitializer = new Random();
            settings.AntialiasingLevel = 10;
            window = new RenderWindow(new VideoMode(800, 500), "Worchbound", Styles.Default, settings);
            projectile.Position = new Vector2f(-10f, -10f);
            player1.Position = new Vector2f(locationInitializer.Next(50, 350), locationInitializer.Next(100, 300));
            player2.Position = new Vector2f(locationInitializer.Next(450, 750), locationInitializer.Next(100, 300));
            player1Gun.Position = new Vector2f(player1.Position.X + 25, player1.Position.Y - 5);
            player2Gun.Position = new Vector2f(player2.Position.X + 25, player2.Position.Y);
            player2Gun.Rotation = 180;
            Text text = new Text();
            window.KeyPressed += Window_KeyPressed;

            while (window.IsOpen)
            {
                window.DispatchEvents();
                window.Clear();
                if (isBallInFlight)
                {
                    projectile = UpdateProjectilePosition(projectile, 0.016f);
                }
                else if (projectile.Position.Y > 500)
                {
                    isBallInFlight = false;
                    if (isPlayer1Turn)
                    {
                        isPlayer1Turn = false;
                    }
                    else if (!isPlayer1Turn)
                    {
                        isPlayer1Turn = true;
                    }
                }
                else if (isPlayer1Turn)
                {
                    if ((projectile.Position.Y + projectile.Radius >= player1.Position.Y) && (projectile.Position.X >= player1.Position.X) && (projectile.Position.X <= player1.Position.X + player1.Size.X))
                    {
                        window.Close();
                    }
                    if ((projectile.Position.X + projectile.Radius >= player1.Position.X) && (projectile.Position.Y >= player1.Position.Y) && (projectile.Position.Y >= player1.Position.Y + player1.Size.Y))
                    {
                        window.Close();
                    }
                    if ((projectile.Position.X + projectile.Radius >= player2.Position.X) && (projectile.Position.Y <= player2.Position.Y) && (projectile.Position.Y >= player2.Position.Y + player2.Size.Y))
                    {
                        window.Close();
                    }
                }
                else if (!isPlayer1Turn)
                {
                    if ((projectile.Position.Y + projectile.Radius >= player2.Position.Y) && (projectile.Position.X <= player2.Position.X) && (projectile.Position.X >= player2.Position.X + player2.Size.X))
                    {
                        window.Close();
                    }
                    if ((projectile.Position.X + projectile.Radius >= player2.Position.X) && (projectile.Position.Y <= player2.Position.Y) && (projectile.Position.Y >= player2.Position.Y + player2.Size.Y))
                    {
                        window.Close();
                    }
                    if (new Vector2f(-projectile.Position.X - projectile.Position.Y, -projectile.Position.X - projectile.Position.Y) == player2.Position)
                    {
                        window.Close();
                    }
                }
                window.SetTitle(v0.ToString());
                window.Draw(text);
                window.Draw(projectile);
                window.Draw(player1);
                window.Draw(player2);
                window.Draw(player1Gun);
                window.Draw(player2Gun);
                window.Display();
            }
        }
开发者ID:bryanzerrudo,项目名称:HW07,代码行数:75,代码来源:Program.cs


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