Clear() public méthode

Clear the entire window with black color
public Clear ( ) : void
Résultat void
Exemple #1
0
        public void Run()
        {
            window = new RenderWindow(new VideoMode(800, 480), "sfml-ui Examples", Styles.Default);
            window.Closed += window_OnCloseRequest;
            window.Resized += window_Resized;

            uimanager = new UISceneManager();
            uimanager.Init(window);

            scene1 = new Scene(ScrollInputs.None);
            scene1.Size = new Vector2f(window.Size.X, window.Size.Y);
            scene1.AddComponent(new TextControl(new Font("font.ttf"), 50) { Size = new Vector2f(800, 100), Color = Color.White, Text = "Hello World", TextAlignment = Alignment.MiddleCenter, Anchor = AnchorPoints.Left | AnchorPoints.Right | AnchorPoints.Top, BackgroundColor = Colors.SteelBlue });
            scene1.AddComponent(new TextControl(new Font("font.ttf"), 16) { Size = new Vector2f(600, 100), Position = new Vector2f(100, 150), Color = Color.Black, Text = "This is an example of sfml-ui, an ui library for SFML.Net", TextAlignment = Alignment.MiddleCenter, Anchor = AnchorPoints.Left | AnchorPoints.Right | AnchorPoints.Top });
            scene1.AddComponent(new PictureControl("example-100.png") { Size = new Vector2f(100, 100), Position = new Vector2f(0, 0), Anchor = AnchorPoints.Left | AnchorPoints.Top });
            scene1.AddComponent(new ButtonControl(new Font("font.ttf"), 16, "button.png", "button_hover.png", "button_pressed.png") { Size = new Vector2f(150, 49), Position = new Vector2f(50, 250), Anchor = AnchorPoints.Left | AnchorPoints.Top, Text = "Press Me :)" });

            uimanager.CurrentScene = scene1;

            while (window.IsOpen())
            {
                window.DispatchEvents();
                window.Clear(Colors.WhiteSmoke);

                uimanager.Render(window);

                window.Display();
            }
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            window = new RenderWindow(new VideoMode(800, 600), "SFML window");
            window.SetVisible(true);
            window.SetVerticalSyncEnabled(true);
            window.Closed += OnClosed;
            window.MouseMoved += OnMouse;
            window.MouseLeft += Window_MouseLeft;
            window.Resized += Window_Resized;

            List<Button> buttons = new List<Button>();

            for (int i = 0; i < 10; i++)
            {
                buttons.Add(new Button(new Vector2f(i*200, 100), new Vector2f(75, 20)));
            }

            while (window.IsOpen)
            {
                window.DispatchEvents();
                window.Clear(new Color(50, 50, 50));
                GUIManager.GuiManager.Update(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y);
                foreach (var item in buttons)
                {
                    window.Draw(item);
                }
                window.Display();
            }
        }
        private static void Main(string[] args)
        {
            var contextSettings = new ContextSettings {
                DepthBits = 32
            };
            var window = new RenderWindow(new VideoMode(640, 480), "JukeSaver spike: SFML Basic", Styles.Default, contextSettings);
            window.SetActive();

            window.Closed += OnClosed;
            window.KeyPressed += OnKeyPressed;

            int r = 0, g = 0, b = 0;
            var shape = new CircleShape() {
                Position = new Vector2f(320, 240),
            };

            while (window.IsOpen()) {
                window.DispatchEvents();
                window.Clear(new Color((byte)r, (byte)g, (byte)b));

                shape.Radius = (float)(80.0 + GetPulse() * 40.0);
                shape.Origin = new Vector2f(shape.Radius * 0.5f, shape.Radius * 0.5f);
                shape.Position = new Vector2f(320 - shape.Radius * 0.5f, 240 - shape.Radius * 0.5f);

                shape.FillColor = new Color(50, (byte)(160 + 80 * GetPulse()), (byte)(40 - (40 * GetPulse())));

                window.Draw(shape);
                window.Display();
            }
        }
Exemple #4
0
 public override void draw(GameTime time, RenderWindow window)
 {
     window.Clear(Color.Black);
     ScreenManager.draw(time, window);
     Log.draw(window);
     window.Display();
 }
        public override void Draw(RenderWindow context, AController controller)
        {
            Controller c = (Controller)controller;

              context.Clear ();
              context.Display ();
        }
Exemple #6
0
        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();
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            // initialize window and view
            win = new RenderWindow(new VideoMode(1000, 700), "Hadoken!!!");
            view = new View();
            resetView();
            gui = new GUI(win, view);

            // exit Program, when window is being closed
            //win.Closed += new EventHandler(closeWindow);
            win.Closed += (sender, e) => { (sender as Window).Close(); };

            // initialize GameState
            handleNewGameState();

            // initialize GameTime
            GameTime gameTime = new GameTime();
            gameTime.Start();

            // debug Text
            Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf"));

            while (running && win.IsOpen())
            {
                KeyboardInputManager.update();

                currentGameState = state.update();

                // gather draw-stuff
                win.Clear(new Color(100, 149, 237));    //cornflowerblue ftw!!! 1337
                state.draw(win, view);
                state.drawGUI(gui);

                // first the state must be drawn, before I can change the currentState
                if (currentGameState != prevGameState)
                {
                    handleNewGameState();
                }

                // do the actual drawing
                win.SetView(view);
                win.Display();

                // check for window-events. e.g. window closed        
                win.DispatchEvents();

                // update GameTime
                gameTime.Update();
                float deltaTime = (float)gameTime.EllapsedTime.TotalSeconds;

                // idleLoop for fixed FrameRate
                float deltaPlusIdleTime = deltaTime;
                while (deltaPlusIdleTime < (1F / fixedFps))
                {
                    gameTime.Update();
                    deltaPlusIdleTime += (float)gameTime.EllapsedTime.TotalSeconds;
                }
                Console.WriteLine("real fps: " + (int)(1F / deltaPlusIdleTime) + ", theo fps: " + (int)(1F / deltaTime));
            }
        }
        public static void Main(String[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1000, 700), "title");
            RenderTexture tex = new RenderTexture(1000, 700);
            Sprite texSprite = new Sprite(tex.Texture);

            Fractal fractal = new Fractal();

            fractal.CreateTreeFractal(500, 700, 3, 100, 0);
            Console.WriteLine(fractal.Nodes.Count);

            while (window.IsOpen())
            {
                window.Clear();
                tex.Clear(new Color(0, 0, 0, 200
                    ));
                foreach (Shape s in fractal.Nodes)
                {
                    window.Draw(s);
                }
                tex.Display();
                window.Draw(texSprite);
                window.Display();
                Image img = window.Capture();
                img.SaveToFile("C:/i.png");
                Console.ReadLine();
            }
        }
Exemple #9
0
        // EINBINDEN VON SFML.NET
        //  - Projektmappen-Explorer öffnen
        //  - Rechtklick -> Verweis hinzufügen
        //  - In der Linkenspalte "Durchsuchen"
        //  - Ganz unten erneut auf "Durchsuchen"
        //  - SFML.NET Ordner öffnen -> Libs
        //  - Alle Auswählen und hinzufügen
        //  - Schauen ob alle markiert sind und OK
        //
        //  - Rechtsklick -> Hinzufügen -> Vorhandenes Element
        //  - SFML.NET Ordner öffnen -> extlibs
        //  - ggf. "Alle Dateitypen (.*)" auswählen
        //  - Alle Auswählen und hinzufügen
        //  - Im Projektmappen-Explorer die 5 .dll auswählen
        //  - Rechtsklick -> Eigenschaften
        //  - Ins Ausgabeverzeichniskopieren -> "Immer kopieren" oder "Kopieren wenn neuer"
        // KONSOLE AUSSCHALTEN
        //  - Projektmappen-Explorer öffnen
        //  - Rechtsklick auf das Projekt (Intro2D-02-Beispiel) -> Eigenschaften
        //  - In den Reiter "Anwendung" (automatisch offen) wechseln
        //  - Ausgabetyp -> "Windows-Anwendung"
        // WICHTIG !!!!!!
        //  - WENN IHR DIESES PROJEKT WEITERVERWENDEN WOLLT, MÜSST IHR DIE VERWEISE (erster Teil) NEU HINZUFÜGEN
        // Wird für Programm ablauf benötigt
        static void Main()
        {
            //initialisiert ein RenderWindow
            RenderWindow win = new RenderWindow(new VideoMode(800, 600), "Test Window");

            //fügt die Close Methode dem Closed Event von dem RenderWindow hinzu
            win.Closed += Close;
            //fancy alternativen:
            //win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };
            //win.Closed += delegate { win.Close(); };

            //solange das Window offen ist
            while (win.IsOpen())
            //in SFML2.2 while(win.IsOpen)
            {
                //hellblau oder so
                win.Clear(new Color(40, 150, 200));

                //trigger alle events
                win.DispatchEvents();

                //zeige alles gezeichnete an
                win.Display();
            }
        }
Exemple #10
0
        static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "Test01");
            window.Closed += (object sender, EventArgs e) => { (sender as Window).Close(); };

            Font font = new Font("SnowflakeLetters.ttf");
            Text text = new Text("BALD IST WEIHNACHTEN!", font);
            Color col1 = new Color(123, 12, 12);
            text.Position = new Vector2f(200, 200);
            CircleShape shape = new CircleShape(20, 8);
            shape.FillColor = Color.White;
            shape.Position = new Vector2f(50, 50);
            float a, c;
            a = c = 50f;

            while (window.IsOpen())
            {
                window.Clear(col1);
                window.Draw(text);
                if (Keyboard.IsKeyPressed(Keyboard.Key.Left) && a > 0)
                    a -= 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Right) && a < window.Size.X - shape.Radius * 2)
                    a += 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Down) && c < window.Size.Y - shape.Radius * 2)
                    c += 0.1f;
                if (Keyboard.IsKeyPressed(Keyboard.Key.Up) && c >  0)
                    c -= 0.1f;
                window.Draw(shape);
                shape.Position = new Vector2f(a, c);

                window.Display();
                window.DispatchEvents();
            }
        }
Exemple #11
0
        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();
            }
        }
Exemple #12
0
        /// <summary>
        /// clear the window
        /// <para>draws all gameobjects in the window</para>
        /// <para>displays all drawn objects</para>
        /// </summary>
        static void Draw(RenderWindow window)
        {
            window.Clear(new Color(50, 120, 190));

            player.Draw(window);
            enemy1.Draw(window);
            enemy2.Draw(window);

            window.Display();
        }
Exemple #13
0
        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();
        }
Exemple #14
0
        /// <summary>
        /// clear the window
        /// <para>draws all gameobjects in the window</para>
        /// <para>displays all drawn objects</para>
        /// </summary>
        static void Draw(RenderWindow window)
        {
            window.Clear(new Color(50, 120, 190));
            window.SetView(Camera);
            map.Draw(window);
            Player.Draw(window);
            enemy1.Draw(window);
            enemy2.Draw(window);

            window.Display();
        }
Exemple #15
0
 static void Draw(RenderWindow window)
 {
     window.Clear(new SFML.Graphics.Color(50, 120, 190));
     map.Draw(window);
     mons01.Draw(window);
     mons02.Draw(window);
       //  vulkan.Draw(window);
     if(tool.isOnMap)tool.Draw(window);
     Player.Draw(window);
     window.Display();
     window.SetView(view);
 }
 public void StartSFMLProgram()
 {
     _window = new RenderWindow(new VideoMode(800, 600), "SFML window");
     _window.SetVisible(true);
     _window.Closed += new EventHandler(OnClosed);
     while (_window.IsOpen)
     {
         _window.DispatchEvents();
         _window.Clear(Color.Red);
         _window.Display();
     }
 }
Exemple #17
0
 public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow window)
 {
     window.Clear(new Color(100, 149, 237));
     if (backedUpGameStateObject != null)
     {
         backedUpGameStateObject.draw(gameTime, window);
     }
     currentGameStateObject.draw(gameTime, window);
     cursor.Position = mouseInput.getMousePos();
     window.Draw(cursor);
     //throw new NotImplementedException();
 }
Exemple #18
0
            public void StartSFMLProgram()
            {
                _window = new RenderWindow(new VideoMode(800, 600), "SFML window");
                _window.SetVisible(true);
                _window.Closed += new EventHandler(OnClosed);

                tests = new Tests(_window);
                Stopwatch watch = new Stopwatch();
                watch.Start();

                Stopwatch pauseWatch = new Stopwatch();
                pauseWatch.Start();
                while (_window.IsOpen())
                {
                    _window.DispatchEvents();
                    _window.Clear();

                    if (watch.ElapsedMilliseconds > 500)
                    {
                        if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Left) && currentTest > 0)
                        {
                            --currentTest;
                            watch.Reset();
                            watch.Start();
                            tests.TestCounter = 1;
                            tests.Paused = false;
                        }
                        else if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Right) && currentTest < 6)
                        {
                            ++currentTest;
                            watch.Reset();
                            watch.Start();
                            tests.TestCounter = 1;
                            tests.Paused = false;
                        }
                    }

                    if (pauseWatch.ElapsedMilliseconds > 250)
                    {
                        if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Space))
                        {
                            tests.Paused = !tests.Paused;
                            pauseWatch.Reset();
                            pauseWatch.Start();
                        }
                    }

                    RunCurrentTest();

                    _window.Display();
                }
            }
Exemple #19
0
        public static void DrawAll(ref RenderWindow window)
        {
            window.Clear();
            window.DispatchEvents();

            foreach (Shape s in shapeList)
                window.Draw(s);

            foreach (Sprite s in spriteList)
                window.Draw(s);

            window.Display();
        }
Exemple #20
0
        public void Run()
        {
            //var mode = new SFML.Window.VideoMode(800, 600);
            var window = new SFML.Graphics.RenderWindow(SFML.Window.VideoMode.FullscreenModes[0], "Repair Project", SFML.Window.Styles.Fullscreen);

            window.KeyPressed += Window_KeyPressed;

            window.MouseButtonPressed  += OnMouseButtonPressed;
            window.MouseButtonReleased += OnMouseButtonReleased;
            window.MouseMoved          += OnMouseMoved;

            //this.object2DManager.SizeScreen = window.GetView().Size;


            SFML.Graphics.View view = window.GetView();
            this.resolutionScreen = new Vector2f(view.Size.X, view.Size.Y);
            view.Center           = new Vector2f(0, 0);
            window.SetView(view);

            window.SetVerticalSyncEnabled(true);

            Clock clock = new Clock();

            this.officeWorld.StartLevel();

            // Start the game loop
            while (window.IsOpen)
            {
                Time deltaTime = clock.Restart();

                // Game logic update
                this.officeWorld.UpdateLogic(deltaTime);

                window.Clear();

                this.object2DManager.DrawIn(window);

                // Process events
                window.DispatchEvents();


                AObject2D.UpdateZoomAnimationManager(deltaTime);

                // Finally, display the rendered frame on screen
                window.Display();
            }

            this.object2DManager.Dispose(this.officeWorld);

            AObject2D.StopAnimationManager();
        }
Exemple #21
0
        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();
            }
        }
        public override void Draw(RenderWindow context, AController controller)
        {
            Controller c = (Controller)controller;

              context.Clear ();

            //      foreach (Ball ball in c.Balls)
            //        ball.Draw (context);
            //
            //      Text text = new Text ("Title Screen");
            //      context.Draw (text);

              context.Draw(TitleScreen);

              context.Display ();
        }
Exemple #23
0
        static void Main(string [] args)
        {
            RenderWindow Window = new RenderWindow(new VideoMode(800, 600), "Teste");
            Map area51 = new Map("map.tmx");
            area51.loadTilesets();
            area51.loadLayers();
            area51.loadImages();

            Window.SetFramerateLimit(20);
            while (true) {
                Window.Clear();
                foreach (Layer lay in area51.layers) {
                    Window.Draw(lay.LayeredSprite);
                }
                Window.Display();
            }
        }
Exemple #24
0
        static void Main(string[] args)
        {
            Controller controller = new Leap.Controller(); // initialize the leap controller

            while (!controller.IsConnected) { } // wait for it to connect

            PhaseModulationProvider pmProvider = new PhaseModulationProvider(440, (440f / 2f), 0.5f, 0.5f, 0.2f); // initialize the pm oscillator

            MixingSampleProvider mixer = new MixingSampleProvider(new[] { pmProvider });

            mixer.ReadFully = true;

            SynthController synthController = new SynthController(pmProvider, 0.1f); // initialize the object that controls the synth with leap

            WaveOut audioOut = new WaveOut(); // hear things

            audioOut.Init(mixer); // give it the oscillator

            audioOut.Play(); // play it

            RenderWindow window = new RenderWindow(new VideoMode(200, 200), "Test Window, Please Ignore"); // make the sfml window

            window.Closed += (object sender, EventArgs e) => // so I can close it
            {
                RenderWindow w = sender as RenderWindow;
                controller.Dispose();
                w.Close();
            };

            window.KeyPressed += (object sender, KeyEventArgs e) =>
            {
                if (e.Code == Keyboard.Key.Escape)
                {
                    RenderWindow w = sender as RenderWindow;
                    w.Close();
                }
            };

            while (window.IsOpen) // main loop
            {
                synthController.HandleFrame(controller);
                window.DispatchEvents();
                window.Clear();
                window.Display();
            }
        }
Exemple #25
0
        static void Main(string[] args)
        {
            SFML.Graphics.RenderWindow window = InitWindow();
            GameWorld          world          = new GameWorld(window);
            AbstractNavigation menu           = new MainMenu();
            AbstractNavigation dialog         = new Dialog("1");
            InputHandlerMenu   inputMenu      = new InputHandlerMenu();
            List <MenuCommand> _temp;

            world.Update();
            ManageSound.Instance.StartPlayingMusic();
            while (window.IsOpen)
            {
                window.Clear();

                //INPUT HANDLING AGAIN!
                _temp = inputMenu.HandleInput();
                foreach (MenuCommand m in _temp)
                {
                    m.Execute(menu);
                    m.Execute(dialog);
                }

                window.Draw(world);

                inputMenu.Flush();
                if (menu.Active)
                {
                    window.Draw(menu);
                }
                else
                {
                    if (dialog.Active)
                    {
                        dialog.Update();
                        window.Draw(dialog);
                    }
                    else
                    {
                        world.Update();
                    }
                }
                window.Display();
            }
        }
Exemple #26
0
        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();
            }
        }
Exemple #27
0
        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();
            }
        }
        private static void Main(string[] args)
        {
            var contextSettings = new ContextSettings { DepthBits = 32 };
            var window = new RenderWindow(new VideoMode(640, 480), "SFML.Net starter kit", Styles.Default, contextSettings);
            window.SetActive();

            window.Closed += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            int r=0,g=0,b=0;
            
            while (window.IsOpen())
            {
                window.DispatchEvents();                
                window.Clear(new Color((byte)r, (byte)g, (byte)b));
                window.Display();
            }
        }
Exemple #29
0
        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();
            }
        }
Exemple #30
0
        public void StartSFMLProgram()
        {
            timer = new Stopwatch();

            _window = new RenderWindow(new VideoMode(800, 600), "SFML window");
            _window.SetVisible(true);
            _window.Closed += new EventHandler(OnClosed);

            Texture tex = new Texture("resources\\Sprites\\Sharpedo.png");
            Sprite spr = new Sprite(tex);

            Text fps = new Text("Fps is", new Font("resources\\gstbinrm.ttf"));
            fps.DisplayedString = "Fps is this";
            fps.Position = new Vector2f(40f, 20f);

            timer.Start();
            int count = 0;
            while (_window.IsOpen())
            {

                if (timer.ElapsedMilliseconds > 0)
                {

                }

                count++;

                if (count > 1000)
                {
                    double time = (double)count / ((double)timer.ElapsedMilliseconds / 1000d);

                    count = 0;
                    timer.Restart();

                    fps.DisplayedString = string.Format("Fps is this: {0}", time);
                }

                _window.DispatchEvents();
                _window.Clear(Color.Red);
                _window.Draw(spr);
                _window.Draw(fps);
                _window.Display();
            }
        }
        public static void StartRender()
        {
            Handlers.Events events = new Handlers.Events();

            DateTime time1;
            DateTime time2;
            float time3;
            double time4;

            RenderWindow window = new RenderWindow(new VideoMode(640, 480 ),"Game");

            window.Closed += new EventHandler(Handlers.EventHandler.OnClose);
            events.Moving += new EventHandler<Handlers.MovingEventArgs>(Handlers.EventHandler.even_Moving);
            events.SearchingEvent += new EventHandler<Handlers.SearchEventArgs>(Handlers.EventHandler.SearchEvent);
            window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(Handlers.MouseHandler.MouseButtonDownHandler);

            Sprite Player = new Sprite();
            Player.Texture = Game_Objects.Player.Instanse.texture;
            Player.TextureRect = new IntRect(0, 0, 150, 150);
            Player.Position = new Vector2f(Game_Objects.Player.Instanse.xPosition, Game_Objects.Player.Instanse.yPosition);
            time1 = DateTime.Now;
            while(window.IsOpen())
            {
                time2 = DateTime.Now;
                time4 = (time2.Ticks - time1.Ticks)*1E-2;
                time3 = (float)time4;
                time1 = DateTime.Now;
                time3 = time3/200;
                window.DispatchEvents();

                if (EventRun)
                {
                    events.SearchEvent(x,y,time3);
                }

                Player.Position = new Vector2f(Game_Objects.Player.Instanse.xPosition, Game_Objects.Player.Instanse.yPosition);
                Player.TextureRect = new IntRect(130*(int)Game_Objects.Player.Instanse.currentFrame+100,0,-100,150);
                window.Clear();
                window.Draw(Player);
                window.Display();

            }
        }
 public static void Start()
 {
     window = new RenderWindow(new VideoMode(1000, 800), "I Am Goc");
     blocks = new List<Block>();
     blockSprite = new Sprite(new Texture("Content/Block.png"),new IntRect(0,0,64,64));
     playerSprite = new Sprite(new Texture("Content/Player.png"), new IntRect(0, 0, 64, 64));
     window.Closed += onWindowClose;
     window.KeyReleased += Player.Move;
     window.SetFramerateLimit(25);
     Level.Load(0);
     while(window.IsOpen())
     {
         window.Clear();
         window.DispatchEvents();
         Update();
         window.Display();
         Level.DrawBackground();
     }
 }
Exemple #33
0
        static void Main(string[] args)
        {
            Player player = new Player();
            Enemy enemy = new Enemy();
            RenderWindow window = new RenderWindow(new VideoMode(800,600),"Fenster");
            window.Closed += Close;
            while (window.IsOpen())
            {
                //Update(window);
                window.Clear(new Color(50,50,150));
                window.DispatchEvents();
                player.move();
               // enemy.move(player.getpositionx,player.getpositiony);
                enemy.Draw(window);
                player.Draw(window);
                window.Display();

            }
        }
        static void Main()
        {
            //Get the splash screen graphic
            System.Windows.SplashScreen EngineSplashScreen = new System.Windows.SplashScreen("Resources/SplashScreen.jpg");
            EngineSplashScreen.Show(true);//Show splash screen

            // initialize the main engine form
            EngineMessage("Intializing Pixel Engine", eEngineMessageType.NONE);
            form = new Form1();
            form.Show(); // show our form

            LoadCfg();   //Load config files

            DrawingSurface rendersurface = new DrawingSurface();

            rendersurface.Size     = new System.Drawing.Size(form.Width, form.Height);
            rendersurface.Location = new System.Drawing.Point(0, 0);
            form.Controls.Add(rendersurface);

            EngineMessage("Pixel Engine Ready!", eEngineMessageType.CONFIRM);

            // initialize sfml
            SFML.Graphics.RenderWindow renderwindow = new SFML.Graphics.RenderWindow(rendersurface.Handle);
            //Main cam
            SFML.Graphics.View mainRenderView = new SFML.Graphics.View(new FloatRect(0, 0, 1920, 1080));
            renderwindow.SetView(mainRenderView);
            //UI Cam
            SFML.Graphics.View uiRenderView = new SFML.Graphics.View(new FloatRect(0, 0, 1920, 1080));

            _scene = new EditorScene(renderwindow, mainRenderView);

            //Initialize the resources form
            resourcesForm          = new ResourcesForm();
            resourcesForm.Size     = new System.Drawing.Size(800, 600);
            resourcesForm.Location = new System.Drawing.Point(form.Location.X + form.Width, form.Location.Y);
            resourcesForm.Show();
            resourcesForm.Disposed += new EventHandler(DisposedResourceForm);

            //Debug: create sprite
            PixelEngineProj.Gameplay.PixelSprite newSprite = new PixelEngineProj.Gameplay.PixelSprite("Resources/SpriteIcon.png", new IntRect(0, 0, 128, 128), new Vector2f(0, 0));
            newSprite.Position = new Vector2f(0, 0);

            Text t = new Text("Testing", new Font("Resources/pixelmix.ttf"));

            // drawing loop
            while (form.Visible)
            {
                System.Windows.Forms.Application.DoEvents();
                renderwindow.DispatchEvents();
                renderwindow.Clear(new SFML.Graphics.Color(40, 40, 40));

                //Draw main scene
                renderwindow.SetView(mainRenderView);
                _scene.Draw(renderwindow);

                renderwindow.SetView(uiRenderView);

                //Draw engine text
                renderwindow.SetView(uiRenderView);
                t.Position = new Vector2f(1700, 100);
                t.Draw(renderwindow, RenderStates.Default);

                renderwindow.Display();
                rendersurface.Size = new System.Drawing.Size(form.Width - 300, form.Height);
            }
        }
Exemple #35
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter your fleet Name");
            string fleet = Console.ReadLine();
            Player p     = new Player(fleet);

            game = new Game("battleship", "NBCC", p, fleet);
            var mode   = new SFML.Window.VideoMode(1000, 600);
            var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");

            game.me.Battlefield.Ready += Battlefield_Ready;
            game.OpponentFound        += Game_OpponentFound;
            game.Lost += Game_Lost;
            game.Won  += Game_Won;
            //game.me.Battlefield.Ready += Battlefield_Ready;
            window.SetFramerateLimit(60);
            //m.connect();
            //window.MouseMoved += Window_MouseMoved;
            window.MouseButtonPressed += Window_MouseButtonPressed;
            //m.gotHit += M_gotHit;

            //window.KeyPressed += Window_KeyPressed;

            //var circle = new SFML.Graphics.CircleShape(100f)
            //{
            //    FillColor = SFML.Graphics.Color.Blue
            //};


            // Start the game loop



            mainName.Font            = main;
            mainName.DisplayedString = game.me.Battlefield.Name;
            mainName.CharacterSize   = 65;
            mainName.FillColor       = Color.Green;
            mainName.Position        = new Vector2f(PLAYER_START_X, PLAYER_START_Y - mainName.CharacterSize - 20);


            mainStatus.Font            = main;
            mainStatus.DisplayedString = game.me.Status.ToString();
            mainStatus.CharacterSize   = 40;
            mainStatus.FillColor       = Color.Yellow;
            mainStatus.Position        = new Vector2f(PLAYER_START_X + (SQUARE_SIZE + SPACING_SIZE) * 6, PLAYER_START_Y - mainName.CharacterSize - 20);



            initEmptyField(fieldMain);
            initEmptyField(fieldOpponent);

            DrawBattlefield(game.me.Battlefield, PLAYER_START_X, PLAYER_START_Y, fieldMain);
            //DrawBattlefield(game.opponent.Battlefield, OPPONENT_START_X, OPPONENT_START_Y, fieldOpponent);


            while (window.IsOpen)
            {
                window.Clear();
                // Process events

                window.DispatchEvents();

                Field f = GetMouseField(Mouse.GetPosition(window));
                switch (f.Player)
                {
                case 1:
                    fieldMain[f.X, f.Y].FillColor = Color.White;
                    break;

                case 2:
                    fieldOpponent[f.X, f.Y].FillColor = Color.White;
                    break;

                default:
                    DrawBattlefield(game.me.Battlefield, PLAYER_START_X, PLAYER_START_Y, fieldMain);
                    if (gameRunning)
                    {
                        DrawBattlefield(game.opponent.Battlefield, OPPONENT_START_X, OPPONENT_START_Y, fieldOpponent);
                    }
                    break;
                }
                //window.Draw(circle);
                if (!(game.opponent is null))        //change to check if ene,y present
                {
                    DisplayBF(window, fieldOpponent, SIZE, opponentName, opponentStatus);
                }
                DisplayBF(window, fieldMain, SIZE, mainName, mainStatus);
                DrawShips(window);
                if (chosenShip != null)
                {
                    DrawShip(Mouse.GetPosition(window), window, chosenShip, Color.Red);
                }
                // Finally, display the rendered frame on screen

                window.Display();
            }
        }
Exemple #36
0
        public void Run()
        {
            var mode = new SFML.Window.VideoMode(800, 600);
            //var window = new SFML.Graphics.RenderWindow(SFML.Window.VideoMode.FullscreenModes[0], "Pokemon Union", SFML.Window.Styles.Fullscreen);
            var window = new SFML.Graphics.RenderWindow(mode, "Pokemon Union");

            window.KeyPressed += Window_KeyPressed;

            window.MouseButtonPressed  += OnMouseButtonPressed;
            window.MouseButtonReleased += OnMouseButtonReleased;
            window.MouseMoved          += OnMouseMoved;

            //this.object2DManager.SizeScreen = window.GetView().Size;


            SFML.Graphics.View view = window.GetView();

            view.Size = new Vector2f(400, 300);

            this.resolutionScreen = new Vector2f(view.Size.X, view.Size.Y);
            view.Center           = new Vector2f(9492, -12595);
            this.SetView(window, view);

            window.SetVerticalSyncEnabled(true);

            Clock clock = new Clock();

            this.landWorld.OnFocusAreaChanged(view.Center / MODEL_TO_VIEW, this.resolutionScreen / MODEL_TO_VIEW);

            // Start the game loop
            while (window.IsOpen)
            {
                Time deltaTime = clock.Restart();

                // Game logic update
                this.landWorld.UpdateLogic(null, deltaTime);

                // Draw window
                AObject2D.UpdateZoomAnimationManager(deltaTime);

                window.Clear();

                this.landWorld2D.DrawIn(window, ref this.boundsView);

                // Process events
                window.DispatchEvents();


                //// To remove after.
                //if (Keyboard.IsKeyPressed(Keyboard.Key.Z))
                //{
                //    view.Center += new Vector2f(0, -2f);
                //}
                //else if(Keyboard.IsKeyPressed(Keyboard.Key.S))
                //{
                //    view.Center += new Vector2f(0, 2f);
                //}

                //if (Keyboard.IsKeyPressed(Keyboard.Key.D))
                //{
                //    view.Center += new Vector2f(2f, 0);
                //}
                //else if (Keyboard.IsKeyPressed(Keyboard.Key.Q))
                //{
                //    view.Center += new Vector2f(-2f, 0);
                //}
                //// Console.WriteLine(view.Center.X + " : " + view.Center.Y);

                //this.landWorld.OnFocusAreaChanged(view.Center / MODEL_TO_VIEW, this.resolutionScreen / MODEL_TO_VIEW, 0);

                //this.SetView(window, view);

                // Finally, display the rendered frame on screen
                window.Display();
            }

            this.landWorld2D.Dispose(this.landWorld);
            this.landWorld.Dispose();

            AObject2D.StopAnimationManager();
        }
Exemple #37
0
            public void Run()
            {
                var mode   = new SFML.Window.VideoMode(800, 600);
                var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");



                window.KeyPressed += Window_KeyPressed;

                var circle = new SFML.Graphics.CircleShape(100f)
                {
                    FillColor = SFML.Graphics.Color.Blue
                };
                Clock clock = new Clock();


                window.SetActive(true);
                //window.PushGLStates();
                GuiImpl.Init(window);
                //window.PopGLStates();
                window.SetActive(false);


                Image   image   = new Image(100, 100, Color.Red);
                Texture texture = new Texture(image);

                // Start the game loop
                while (window.IsOpen)
                {
                    // Process events
                    window.DispatchEvents();
                    window.SetActive(true);
                    //window.PushGLStates();

                    GuiImpl.Update(window, clock.Restart());
                    ImGui.BeginMainMenuBar();
                    if (ImGui.BeginMenu("File"))
                    {
                        ImGui.MenuItem("Open");
                        ImGui.EndMenu();
                    }
                    ImGui.EndMainMenuBar();

                    ImGui.Begin("Hello, world!");
                    if (ImGui.Button("Look at this pretty button"))
                    {
                        System.Console.WriteLine("Hi!");
                    }

                    //System.Console.WriteLine(texture.NativeHandle);
                    ImGui.Image(new IntPtr(texture.NativeHandle), new System.Numerics.Vector2(200, 200));
                    ImGui.End();

                    ImGui.Begin("Hello, world!2");
                    if (ImGui.Button("Look at this pretty button22"))
                    {
                        System.Console.WriteLine("Hi2!");
                    }
                    ImGui.Text("Hallo");
                    ImGui.End();
                    ImGui.Button("lll");

                    //window.PopGLStates();
                    window.SetActive(false);


                    window.Clear();
                    window.Draw(circle);
                    GuiImpl.Render();
                    // Finally, display the rendered frame on screen
                    window.Display();
                }
                GuiImpl.Shutdown();
            }