SetTitle() public méthode

Change the title of the window
public SetTitle ( string title ) : void
title string New title
Résultat void
Exemple #1
0
        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;
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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)");
            }
        }
Exemple #4
0
        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();
                    }
                }
            }
        }
Exemple #5
0
        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)));
            }
        }
Exemple #6
0
        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)");
            }
        }
Exemple #7
0
        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();
                    }
                }
            }
        }
Exemple #8
0
        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();
            }
        }