Пример #1
0
        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();
            }
        }
Пример #2
0
        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();
            }
        }
Пример #3
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();
            }
        }
Пример #4
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();
            }
        }
Пример #5
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();
            }
        }
Пример #6
0
        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;
        }
Пример #7
0
        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;
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            Files.log("Game started.");

            Console.Title = "Asialaide";

            new Character("Player", 1, 200, 300);

            Drawing.initialise();
            window = Drawing.window; // A local reference.

            // Create events.
            window.Closed += new EventHandler(Program.OnClose);
            window.KeyPressed += new EventHandler<KeyEventArgs>(Input.OnKeyPressed);

            // Load files.
            Files.load("data\\graphics\\crf_char.png");

            // The game loop.
            while (window.IsOpen())
            {
                // Process events.
                window.DispatchEvents();

                // Draw everything.
                Drawing.drawWindow();
            }
        }
Пример #9
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();
            }
        }
Пример #10
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));
            }
        }
Пример #11
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();
        }
Пример #12
0
        static void Main(string[] args)
        {
            RenderWindow win = new RenderWindow(new VideoMode(900,900), "Intro-2D-Project",Styles.Default);
                win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };
                Initialize();

                while (win.IsOpen()){
                    Update();
                    Draw(win);
                    win.DispatchEvents();
                }
        }
Пример #13
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();
                }
            }
Пример #14
0
        public static void Main()
        {
            #region Initialize Variables
            window = new RenderWindow(new VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Reflexes For Friends", Styles.Default, new ContextSettings(32, 0));
            timer = new Stopwatch();
            world = new GameWorld(new Texture("resources/background-grass.png"));
            player = new Player(new Texture("resources/player.png"));
            friend = new Friend(new Texture("resources/friend.png"));
            enemies = new List<Enemy>();
            gameOver = false;
            #endregion

            #region Register Event Handlers
            window.Closed += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
            window.KeyReleased += new EventHandler<KeyEventArgs>(OnKeyReleased);
            #endregion

            #region Setup Modules
            keyboardModule = new KeyboardModule();
            #endregion

            RegisterKeyBindings();
            GenerateEnemies();

            timer.Start();
            long timeSinceLastUpdate = 0;

            window.SetVerticalSyncEnabled(true);
            window.SetActive();
            while (window.IsOpen())
            {
                window.DispatchEvents();

                if (!gameOver)
                {
                    timeSinceLastUpdate += timer.ElapsedMilliseconds;
                    timer.Restart();
                    if (timeSinceLastUpdate >= UPDATE_FREQUENCY_IN_MS)
                    {
                        UpdateGame(UPDATE_FREQUENCY_IN_MS);

                        timeSinceLastUpdate -= UPDATE_FREQUENCY_IN_MS;
                    }
                }

                DrawGame();
                window.Display();
            }
            timer.Stop();
        }
Пример #15
0
        static void Main(string[] args)
        {
            RenderWindow win = new RenderWindow(new VideoMode(1200, 1000), "Intro2D-04-Beispiel-Player-Enemy");
            win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };

            Initialize();

            while (win.IsOpen())
            {
                Update();
                Draw(win);
                win.DispatchEvents();
            }
        }
Пример #16
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();
            }
        }
Пример #17
0
 public static void Start()
 {
     pixels = new List<Pixel>();
     window = new RenderWindow(new VideoMode((uint)Width,(uint)Height), "I Am Goc");
     window.SetFramerateLimit(120);
     Load();
     window.MouseMoved += setMousePos;
     while (window.IsOpen()){
         window.SetActive();
         window.DispatchEvents();
         Update();
         window.Display();
         Count++;
     }
 }
Пример #18
0
        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();
            }
        }
Пример #19
0
        static void Main(string[] args)
        {
            RenderWindow win = new RenderWindow(new VideoMode(800, 600), "Intro2D-03-Beispiel-Player-Enemy");
            win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };

            //initialize Player and Enemies, by calling the constructors
            player = new Player();
            enemy1 = new Enemy("Pictures/EnemyGreen.png", new Vector2f(900,100));
            enemy2 = new Enemy("Pictures/EnemyRed.png", new Vector2f(100,600) );

            while (win.IsOpen())
            {
                Update();
                Draw(win);
                win.DispatchEvents();
            }
        }
Пример #20
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();
            }
        }
Пример #21
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();
            }
        }
Пример #22
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();
            }
        }
Пример #23
0
        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();
            }
        }
Пример #24
0
 public ScreenManager()
 {
     Window = new RenderWindow(new VideoMode(800, 600, 32), "",Styles.Resize);
     keybinds = new KeyBinding();
     Window.KeyPressed += new EventHandler<KeyEventArgs>(InputSystem_KeyDown);
     Window.KeyReleased += new EventHandler<KeyEventArgs>(InputSystem_KeyUp);
     Window.TextEntered += new EventHandler<TextEventArgs>(InputSystem_CharEntered);
     Window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(InputSystem_MouseDown);
     Window.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(InputSystem_MouseUp);
     Window.MouseMoved += new EventHandler<MouseMoveEventArgs>(InputSystem_MouseMove);
     Window.MouseWheelMoved += new EventHandler<MouseWheelEventArgs>(InputSystem_MouseWheel);
     AddScreen(new UserInterface.Screens.MainMenuScreen());
     Window.SetFramerateLimit(60);
     while (Window.IsOpen())
     {
         GameLoop();
     }
 }
Пример #25
0
        public static void Main()
        {
            // Erzeuge ein neues Fenster
            RenderWindow win = new RenderWindow(new VideoMode(800, 600), "Mein erstes Fenster");

            // Achte darauf, ob Fenster geschlossen wird
            win.Closed += Win_Closed;

            Initialize();
            // Das eigentliche Spiel
            while (win.IsOpen())
            {
                Draw(win);
                Update();
                // Schauen ob Fenster geschlossen werden soll
                win.DispatchEvents();
            }
        }
Пример #26
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();
            }
        }
Пример #27
0
        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();

            }
        }
Пример #28
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();

            }
        }
Пример #29
0
 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();
     }
 }
Пример #30
0
        public static void Main()
        {
            var resolution = new VideoMode(WIDTH, HEIGHT, 32);
            var windowSettings = new ContextSettings(32, 0, 4);
            var window = new RenderWindow(resolution, "Lockheed the Game", Styles.Close, windowSettings);

            window.Closed += Events.OnClose;
            window.KeyPressed += Events.OnKeyPressed;
            window.KeyReleased += Events.OnKeyReleased;
            window.MouseButtonPressed += Events.OnMouseButtonPressed;
            window.SetActive();

            Level.Level newLevel = Level.Level.GenerateSingleLevel();
            Character.Character glava = new Rogue("glava");

            glava.CurrentSkill = new ProjectileSkill(
                "fireball", 10, 10, 10, Tier.Beginner, 5, "weapons/projectiles/fireBall.png", 5);

            EntityManager.CurrentLevel = newLevel;
            EntityManager.Character = glava;

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

                while (dt > 0)
                {
                    EntityManager.Update();
                    dt -= MAX_TIMESTEP;
                }

                window.Clear(Color.Black);
                EntityManager.Draw(window);
                window.Display();
            }
        }