Example #1
0
        public short RunMainMenu()
        {
            //Events
            short result = -2;
            short tampon = 0;

            if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
            {
                _window.Close();
                result = -5;
            }

            if (Keyboard.IsKeyPressed(Keyboard.Key.Enter))
            {
                if (_selected == 4)
                {
                    result = -5;
                }
                else
                {
                    result = (short)_selected;
                }

                while (Keyboard.IsKeyPressed(Keyboard.Key.Enter))
                {
                    ;                                               //tampon
                }
            }

            if (Keyboard.IsKeyPressed(Keyboard.Key.Down) && _selected < MAX_LINES - 1)
            {
                tampon = 1;
                _selected++;
            }
            else if (Keyboard.IsKeyPressed(Keyboard.Key.Up) && _selected > 0)
            {
                tampon = 2;
                _selected--;
            }


            //Graphics
            _window.Clear();
            _window.Draw(_background);

            for (int i = 0; i < MAX_LINES; i++)
            {
                RectangleShape r = null;

                if (i == _selected)
                {
                    r                   = new RectangleShape(new SFML.System.Vector2f(_lines[i].GetGlobalBounds().Width * 1.5f + 20, _lines[i].GetGlobalBounds().Height * 2 + 20));
                    r.Position          = new SFML.System.Vector2f(_window.Size.X / 2 - (r.GetGlobalBounds().Width) / 2, (_window.Size.Y / 7) * (i + 1) - (_lines[i].GetGlobalBounds().Height / 3) - 10);
                    r.FillColor         = Color.Black;
                    _lines[i].FillColor = Color.White;
                }
                else
                {
                    r                   = new RectangleShape(new SFML.System.Vector2f(_lines[i].GetGlobalBounds().Width * 1.5f, _lines[i].GetGlobalBounds().Height * 2));
                    r.Position          = new SFML.System.Vector2f(_window.Size.X / 2 - (r.GetGlobalBounds().Width) / 2, (_window.Size.Y / 7) * (i + 1) - (_lines[i].GetGlobalBounds().Height / 3));
                    r.FillColor         = Color.White;
                    _lines[i].FillColor = Color.Black;
                }

                _window.Draw(r);
                _window.Draw(_lines[i]);
            }

            _window.Display();

            if (tampon == 1)
            {
                while (Keyboard.IsKeyPressed(Keyboard.Key.Down))
                {
                    ;                                              //Tampon
                }
            }
            else if (tampon == 2)
            {
                while (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                {
                    ;                                            //Tampon
                }
            }

            return(result);
        }
Example #2
0
 //for showing the output
 public virtual void Render(RenderWindow window)
 {
     window.Clear(backgroundColor);
     DrawMouseInteractive(window);
 }
Example #3
0
 static void draw(RenderWindow win, GameTime time)
 {
     win.Clear();
     Runner.draw(win);
     win.Display();
 }
Example #4
0
        public void Start()
        {
            //game window
            window         = new RenderWindow(new VideoMode(World.WIDTH * 16, World.HEIGHT * 16), "Space War!");
            window.Closed += new EventHandler(OnClose);
            window.SetVerticalSyncEnabled(true);

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

                KeyboardControl(player, bullets);
                window.Draw(map);

                if (!isMenuOpen)
                {
                    Draw();

                    //move enemies and bullets and check if hitting
                    for (int i = 0; i < enemies.Count; i++)
                    {
                        if (random.Next(0, 30) == 0)
                        {
                            bullets.Add(enemies[i].Fire(new Sprite(sprite)));
                        }
                        for (int j = 0; j < bullets.Count && enemies.Count > 0; j++)
                        {
                            if (enemies[i].isHitting(bullets[j]) ||
                                player.isHitting(bullets[j]))
                            {
                                bullets.RemoveAt(j);
                                if (j > 0)
                                {
                                    --j;
                                }
                                if (enemies[i].GetHealth() <= 0 ||
                                    enemies[i].GetPosition().Y > World.HEIGHT * 16)
                                {
                                    enemies.RemoveAt(i);
                                    score++;
                                    if (i > 0)
                                    {
                                        --i;
                                    }
                                }
                            }
                        }
                    }

                    for (int j = 0; j < bullets.Count; j++)
                    {
                        if (bullets[j].GetPosition().Y <0 ||
                                                        bullets[j].GetPosition().Y> World.HEIGHT * 16)
                        {
                            bullets.RemoveAt(j);
                            if (j > 0)
                            {
                                --j;
                            }
                        }
                    }

                    //spawn new enemies
                    if (enemySpawnFrequency > 0)
                    {
                        enemySpawnFrequency--;
                    }
                    if (enemySpawnFrequency == 0)
                    {
                        enemySpawnFrequency = random.Next(55, 100);
                        enemies.Add(new Enemy(new Sprite(sprite), player));
                    }

                    //spawn new black hole
                    if (blackHoleSpawnFrequency > 0)
                    {
                        blackHoleSpawnFrequency--;
                    }
                    if (blackHoleSpawnFrequency == 0)
                    {
                        blackHoleSpawnFrequency = random.Next(300, 500);
                        blackHoles.Add(new BlackHole(new Sprite(sprite)));
                    }

                    //spawn new black hole
                    if (blackHoleSpawnFrequency > 0)
                    {
                        blackHoleSpawnFrequency--;
                    }
                    if (blackHoleSpawnFrequency == 0)
                    {
                        boosterSpawnFrequency = random.Next(200, 500);
                        boosters.Add(new Booster(new Sprite(sprite)));
                    }

                    //draw black holes
                    for (int k = 0; k < blackHoles.Count; k++)
                    {
                        if (blackHoles[k].GetPosition().Y > World.HEIGHT * 16 ||
                            player.isBlackHole(blackHoles[k]))
                        {
                            blackHoles.RemoveAt(k);
                            if (k > 0)
                            {
                                k--;
                            }
                        }
                    }

                    //draw boosters
                    for (int k = 0; k < boosters.Count; k++)
                    {
                        if (boosters[k].GetPosition().Y > World.HEIGHT * 16 ||
                            player.isBooster(boosters[k]))
                        {
                            boosters.RemoveAt(k);
                            if (k > 0)
                            {
                                k--;
                            }
                        }
                    }

                    if (player.health <= 0) //end of game
                    {
                        isMenuOpen  = true;
                        isEndOfGame = true;
                    }
                }
                else
                {
                    window.Draw(menuArea);
                    window.Draw(reloadIcon);
                    Text distance = new Text("0", font, 25)
                    {
                        FillColor = Color.White,
                        Position  = new Vector2f(150, 220)
                    };
                    uint dis = (uint)world.GetDistance();
                    distance.DisplayedString = "distance: " + dis + "\n" + "score: " + score + "\n" + "best: " + bestScore +
                                               "\n\n\n\n\n\n\n\n" + "  Esc - resume\nEnter - restart";
                    window.Draw(distance);
                    if (isEndOfGame && score > bestScore)
                    {
                        bestScore = score;
                    }
                }
                window.Display();
            }
        }
Example #5
0
 private void Draw()
 {
     window.Clear();
     gameManager.Draw(window);
     window.Display();
 }
Example #6
0
        private void FindCrash(List <string> tracks)
        {
            // First find width and height of map
            int WIDTH  = tracks.Max(a => a.Length);
            int HEIGHT = tracks.Count();

            SIZE = 1050 / WIDTH;

            Console.WriteLine($"Dimensions: {WIDTH}x{HEIGHT}");

            List <Kart> Karts = new List <Kart>();

            Track[,] Map = new Track[WIDTH, HEIGHT];
            // Initialise map
            for (int x = 0; x < WIDTH; x++)
            {
                for (int y = 0; y < HEIGHT; y++)
                {
                    Map[x, y] = new Track(x, y, Track.TrackType.EMPTY);
                }
            }

            // Fill map
            int index = 0;

            foreach (var track in tracks)
            {
                char[] temp = track.ToCharArray();
                for (int x = 0; x < track.Count(); x++)
                {
                    // Check if vertical
                    if (temp[x] == '|' || temp[x] == 'v' || temp[x] == '^')
                    {
                        Map[x, index] = new Track(x, index, Track.TrackType.VERTICAL);

                        if (temp[x] == 'v')
                        {
                            Karts.Add(new Kart(x, index, Kart.Direction.DOWN));
                        }
                        else if (temp[x] == '^')
                        {
                            Karts.Add(new Kart(x, index, Kart.Direction.UP));
                        }
                    }
                    else if (temp[x] == '-' || temp[x] == '<' || temp[x] == '>')
                    {
                        Map[x, index] = new Track(x, index, Track.TrackType.HORIZONTAL);

                        if (temp[x] == '<')
                        {
                            Karts.Add(new Kart(x, index, Kart.Direction.LEFT));
                        }
                        else if (temp[x] == '>')
                        {
                            Karts.Add(new Kart(x, index, Kart.Direction.RIGHT));
                        }
                    }
                    else if (temp[x] == '+')
                    {
                        Map[x, index] = new Track(x, index, Track.TrackType.CROSS);
                    }
                    else if (temp[x] == '/')
                    {
                        Map[x, index] = new Track(x, index, Track.TrackType.CORNERSE);
                    }
                    else if (temp[x] == '\\')
                    {
                        Map[x, index] = new Track(x, index, Track.TrackType.CORNERNE);
                    }
                }
                index++;
            }


            //RenderWindow window = new RenderWindow(
            //    new SFML.Window.VideoMode((uint)(WIDTH * SIZE),(uint)(HEIGHT * SIZE)),
            //    "Day 13");


            RenderWindow window = new RenderWindow(
                new SFML.Window.VideoMode(1050, 1050),
                "Day 13");

            window.SetActive();

            Application.EnableVisualStyles();


            window.Clear();
            window.DispatchEvents();
            for (int x = 0; x < WIDTH; x++)
            {
                for (int y = 0; y < HEIGHT; y++)
                {
                    window.Draw(Map[x, y].Shape);
                }
            }
            Karts.ForEach(a => window.Draw(a.Shape));

            window.Display();

            Thread.Sleep(3000);

            int TotalKarts      = Karts.Count();
            int TotalCollisions = 0;

            //for(int i = 0; i < 30; i++)
            while (true)
            {
                Karts.Sort();
                for (int k = 0; k < TotalKarts; k++)
                {
                    Karts[k].Update(Map);
                    // Check for collision
                    for (int i = 0; i < Karts.Count(); i++)
                    {
                        for (int j = i + 1; j < Karts.Count(); j++)
                        {
                            if (Karts[i].X == Karts[j].X &&
                                Karts[i].Y == Karts[j].Y &&
                                !Karts[i].Collided &&
                                !Karts[j].Collided)
                            {
                                Karts[i].Collided        = true;
                                Karts[j].Collided        = true;
                                Karts[i].Shape.FillColor = new Color(0, 0, 255, 100);
                                Karts[j].Shape.FillColor = new Color(0, 0, 255, 100);
                                Karts[i].UpdateRadius(1.0f);
                                Karts[j].UpdateRadius(1.0f);

                                Console.WriteLine($"Collision at {Karts[i].X},{Karts[i].Y}");
                                TotalCollisions += 2;
                            }
                        }
                    }
                }
                ////Karts.ForEach(a => a.Update(Map));



                if (true)
                {
                    window.Clear();
                    window.DispatchEvents();
                    for (int x = 0; x < WIDTH; x++)
                    {
                        for (int y = 0; y < HEIGHT; y++)
                        {
                            window.Draw(Map[x, y].Shape);
                        }
                    }
                    Karts.ForEach(a => window.Draw(a.Shape));

                    window.Display();
                }

                // Stop Code PART ONE
                if (TotalCollisions == TotalKarts)
                {
                    break;
                }

                // Stop Code PART TWO
                if (TotalKarts - TotalCollisions == 1)
                {
                    Kart Last = Karts.Find(a => a.Collided == false);
                    Console.WriteLine($"The last kart's position is: {Last.X},{Last.Y}");
                    break;
                }
                //Thread.Sleep(500);
            }

            Console.WriteLine("Everything has collided!");
            Thread.Sleep(3000);
        }
Example #7
0
        static void Main()
        {
            window = new RenderWindow(new VideoMode(1280, 720), "", Styles.Close);
            window.SetFramerateLimit(60);
            window.Closed += (sender, eventArgs) => window.Close();

            shipTex     = new Texture("Ship.png");
            asteroidTex = new Texture("Asteroid.png");

            var shipSpr = new Sprite(shipTex);

            shipSpr.Origin = new Vector2f(shipTex.Size.X / 2f, shipTex.Size.Y / 2f);

            var asteroidSpr = new Sprite(asteroidTex);

            asteroidSpr.Origin = new Vector2f(asteroidTex.Size.X / 2f, asteroidTex.Size.Y / 2f);

            world = new World(new Vector2(0, 0));

            var debugView = new SFMLDebugView(world);

            debugView.AppendFlags(DebugViewFlags.Shape);

            CreateBounds(20, 11.25f);

            var ship = CreateShip();

            ship.Position = new Vector2(3, 1);
            ship.Rotation = 1.7f;

            var ship2 = CreateShip();

            ship2.Position = new Vector2(3, 1);
            ship2.Rotation = 1.7f;

            var asteroid = CreateAsteroid();

            asteroid.Position = new Vector2(4, 4);

            window.KeyPressed += (sender, eventArgs) =>
            {
                if (eventArgs.Code == Keyboard.Key.Space)
                {
                    CreateBullets(ship);
                }
            };

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

                if (Keyboard.IsKeyPressed(Keyboard.Key.W))
                {
                    ship.ApplyForce(ship.GetWorldVector(new Vector2(0.0f, -25.0f)));
                }

                if (Keyboard.IsKeyPressed(Keyboard.Key.S))
                {
                    ship.ApplyForce(ship.GetWorldVector(new Vector2(0.0f, 25.0f)));
                }

                if (Keyboard.IsKeyPressed(Keyboard.Key.A))
                {
                    ship.ApplyTorque(-10);
                }

                if (Keyboard.IsKeyPressed(Keyboard.Key.D))
                {
                    ship.ApplyTorque(10);
                }

                world.Step(1f / 60);

                window.Clear(Color.Black);

                shipSpr.Position = new Vector2f(ship.Position.X * 64, ship.Position.Y * 64);
                shipSpr.Rotation = (ship.Rotation * (180 / (float)Math.PI));
                window.Draw(shipSpr);

                asteroidSpr.Position = new Vector2f(asteroid.Position.X * 64, asteroid.Position.Y * 64);
                asteroidSpr.Rotation = (asteroid.Rotation * (180 / (float)Math.PI));
                window.Draw(asteroidSpr);

                var  start = ship.Position;
                var  step  = (float)(2 * Math.PI) / 200;
                byte col   = 0;
                var  line  = new VertexArray(PrimitiveType.Lines, 2);
                line[0] = new Vertex(new Vector2f(start.X * 64, start.Y * 64), Color.White);
                for (var dir = 0f; dir <= 2 * Math.PI; dir += step)
                {
                    float min   = 100;
                    byte  res   = 255;
                    var   point = start + LengthDir(dir, 20);
                    world.RayCast((f, p, n, fr) =>
                    {
                        if (fr > min)
                        {
                            return(1);
                        }

                        min   = fr;
                        res   = (byte)(fr * 255);
                        point = p;
                        return(fr);
                    }, start, point);

                    line[0] = new Vertex(new Vector2f(start.X * 64, start.Y * 64), new Color(col, 0, 0));
                    line[1] = new Vertex(new Vector2f(point.X * 64, point.Y * 64), new Color(col, 0, 0));
                    window.Draw(line);
                    col++;
                }

                debugView.Draw(window);

                window.Display();
            }
        }
Example #8
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Create the main window
            RenderWindow App = new RenderWindow(new VideoMode(800, 600), "SFML.Net PostFX");

            // Setup event handlers
            App.Closed     += new EventHandler(OnClosed);
            App.KeyPressed += new EventHandler <KeyEventArgs>(OnKeyPressed);

            // Check that the system can use post effects
            if (PostFx.CanUsePostFX == false)
            {
                DisplayError(App);
                return;
            }

            // Load a cute background image to display :)
            Sprite Background = new Sprite(new Image("datas/post-fx/background.jpg"));

            // Load the text font
            Font Cheeseburger = new Font("datas/post-fx/cheeseburger.ttf");

            // Load the image needed for the wave effect
            Image WaveImage = new Image("datas/post-fx/wave.jpg");

            // Load all effects
            Effects             = new Dictionary <string, PostFx>();
            Effects["nothing"]  = new PostFx("datas/post-fx/nothing.sfx");
            Effects["blur"]     = new PostFx("datas/post-fx/blur.sfx");
            Effects["colorize"] = new PostFx("datas/post-fx/colorize.sfx");
            Effects["fisheye"]  = new PostFx("datas/post-fx/fisheye.sfx");
            Effects["wave"]     = new PostFx("datas/post-fx/wave.sfx");
            CurrentEffect       = Effects.GetEnumerator();
            CurrentEffect.MoveNext();

            // Do specific initializations
            Effects["nothing"].SetTexture("framebuffer", null);
            Effects["blur"].SetTexture("framebuffer", null);
            Effects["blur"].SetParameter("offset", 0.0F);
            Effects["colorize"].SetTexture("framebuffer", null);
            Effects["colorize"].SetParameter("color", 1.0F, 1.0F, 1.0F);
            Effects["fisheye"].SetTexture("framebuffer", null);
            Effects["wave"].SetTexture("framebuffer", null);
            Effects["wave"].SetTexture("wave", WaveImage);

            // Define a string for displaying current effect description
            CurFXStr          = new String2D();
            CurFXStr.Text     = "Current effect is \"" + CurrentEffect.Current.Key + "\"";
            CurFXStr.Font     = Cheeseburger;
            CurFXStr.Position = new Vector2(20.0F, 0.0F);

            // Define a string for displaying help
            String2D InfoStr = new String2D();

            InfoStr.Text     = "Move your mouse to change the effect parameters\nPress numpad + to change effect\nWarning : some effects may not work\ndepending on your graphics card";
            InfoStr.Font     = Cheeseburger;
            InfoStr.Position = new Vector2(20.0F, 460.0F);
            InfoStr.Color    = new Color(200, 100, 150);

            // Start the game loop
            while (App.IsOpened())
            {
                // Process events
                App.DispatchEvents();

                // Get the mouse position in the range [0, 1]
                float X = App.Input.GetMouseX() / (float)App.Width;
                float Y = App.Input.GetMouseY() / (float)App.Height;

                // Update the current effect
                if (CurrentEffect.Current.Key == "blur")
                {
                    CurrentEffect.Current.Value.SetParameter("offset", X * Y * 0.1f);
                }
                else if (CurrentEffect.Current.Key == "colorize")
                {
                    CurrentEffect.Current.Value.SetParameter("color", 0.3f, X, Y);
                }
                else if (CurrentEffect.Current.Key == "fisheye")
                {
                    CurrentEffect.Current.Value.SetParameter("mouse", X, 1.0F - Y);
                }
                else if (CurrentEffect.Current.Key == "wave")
                {
                    CurrentEffect.Current.Value.SetParameter("offset", X, Y);
                }

                // Clear the window
                App.Clear();

                // Draw background and apply the post-fx
                App.Draw(Background);
                App.Draw(CurrentEffect.Current.Value);

                // Draw interface strings
                App.Draw(CurFXStr);
                App.Draw(InfoStr);

                // Finally, display the rendered frame on screen
                App.Display();
            }
        }
Example #9
0
        public void Run()
        {
            dispWindow      = new RenderWindow(VideoMode.DesktopMode, "RaceGame", Styles.Default);
            dispWindow.Size = windowSize;
            dispWindow.SetVerticalSyncEnabled(true);
            dispWindow.Closed += DispWindow_Closed;
            dispWindow.SetView(new View((Vector2f)windowSize / 2, (Vector2f)windowSize));

            Color clearCol = new Color(40, 40, 40);

            //GroupShape myPath = new GroupShape(LoadObjects("racepath4"), new Vector2f(1, 1));
            List <Cart> cartList = new List <Cart>();

            CorrectPath path = null;


            GroupShape map = new GroupShape(LoadFromPoly(out path, "testRacePath8"), new Vector2f(1, 1));

            foreach (ConvexShape shap in path.path.shapes)
            {
                shap.FillColor = new Color(shap.FillColor.R, shap.FillColor.G, shap.FillColor.B, 30);
            }

            List <GroupShape> mapList = new List <GroupShape>()
            {
                map,
            };

            Cart car  = new Cart(new GroupShape(LoadObjects("car1"), path.path.shapes[0].Position + (path.path.shapes[0].GetPoint(0) + path.path.shapes[0].GetPoint(1)) * .5F));
            Cart car2 = new Cart(new GroupShape(LoadObjects("car1"), path.path.shapes[0].Position + (path.path.shapes[0].GetPoint(0) + path.path.shapes[0].GetPoint(1)) * .5F));

            CarInterface carInt1 = new CarInterface(car, path);
            ExampleRobot myRobot = new ExampleRobot(carInt1);

            cartList.Add(car);
            cartList.Add(car2);

            //StartObjectEditor(dispWindow);

            //* Main game loop
            while (isRunning)
            {
                dispWindow.DispatchEvents();
                dispWindow.Clear(clearCol);

                //Begin logic
                //-----------
                Vector2f relativeMousePos = new Vector2f((((float)Mouse.GetPosition(dispWindow).X / (float)windowSize.X) * (float)zoomSize.X) + ((float)dispWindow.GetView().Center.X - (.5F * (float)zoomSize.X)),
                                                         (((float)Mouse.GetPosition(dispWindow).Y / (float)windowSize.Y) * (float)zoomSize.Y) + ((float)dispWindow.GetView().Center.Y - (.5F * (float)zoomSize.Y)));


                myRobot.Update();

                if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                {
                    car.Drive(1);
                }
                if (Keyboard.IsKeyPressed(Keyboard.Key.Down))
                {
                    car.Drive(-1);
                }
                if (Keyboard.IsKeyPressed(Keyboard.Key.Left))
                {
                    car.Turn(-1);
                }
                if (Keyboard.IsKeyPressed(Keyboard.Key.Right))
                {
                    car.Turn(1);
                }
                if (Keyboard.IsKeyPressed(Keyboard.Key.Space))
                {
                    car.Brake(1F);
                }
                if (Mouse.IsButtonPressed(Mouse.Button.Left))
                {
                    car.Position = relativeMousePos;
                }

                //Set View
                Vector2f mySize   = (Vector2f)dispWindow.Size;
                Vector2f startPos = new Vector2f(float.MaxValue, float.MaxValue);
                Vector2f endPos   = new Vector2f(float.MinValue, float.MinValue);
                foreach (Cart x in cartList)
                {
                    if (x.Position.X < startPos.X)
                    {
                        startPos.X = x.Position.X;
                    }
                    if (x.Position.Y < startPos.Y)
                    {
                        startPos.Y = x.Position.Y;
                    }
                    if (x.Position.X > endPos.X)
                    {
                        endPos.X = x.Position.X;
                    }
                    if (x.Position.Y > endPos.Y)
                    {
                        endPos.Y = x.Position.Y;
                    }
                }
                startPos -= new Vector2f(100, 100);
                endPos   += new Vector2f(100, 100);
                if (endPos.X - startPos.X < mySize.X && endPos.Y - startPos.Y < mySize.Y)
                {
                    if (startPos.X < prevWindowPos.X)
                    {
                        prevWindowPos = new Vector2f(startPos.X, prevWindowPos.Y);
                    }
                    if (startPos.Y < prevWindowPos.Y)
                    {
                        prevWindowPos = new Vector2f(prevWindowPos.X, startPos.Y);
                    }
                    if (endPos.X - mySize.X > prevWindowPos.X)
                    {
                        prevWindowPos = new Vector2f(endPos.X - mySize.X, prevWindowPos.Y);
                    }
                    if (endPos.Y - mySize.Y > prevWindowPos.Y)
                    {
                        prevWindowPos = new Vector2f(prevWindowPos.X, endPos.Y - mySize.Y);
                    }
                    dispWindow.SetView(new View(prevWindowPos + .5F * mySize, mySize));
                }
                else
                {
                    endPos -= startPos;
                    if (endPos.X / mySize.X > endPos.Y / mySize.Y)
                    {
                        endPos.Y = endPos.X * mySize.Y / mySize.X;
                    }
                    else
                    {
                        endPos.X = endPos.Y * mySize.X / mySize.Y;
                    }
                    dispWindow.SetView(new View(startPos + .5F * endPos, endPos));
                }
                //--


                cartList.ForEach(x => x.Update());
                cartList.ForEach(x => x.CollisionCheck(mapList));


                //FINAL stage logic
                Debug.FinishUp();

                //Logic is done, begin drawing
                //----------------------------
                path.path.Draw(dispWindow, rs);
                map.Draw(dispWindow, rs);
                cartList.ForEach(x => x.Draw(dispWindow, rs));
                Debug.Draw(dispWindow, rs);
                dispWindow.Display();
            }// */ // End main game loop
        }
Example #10
0
        static void Main(string[] args)
        {
            //*****************
            //* Configuration *
            //*****************


            //Velcro
            VelcroPhysics.Settings.ContinuousPhysics  = true;
            VelcroPhysics.Settings.PositionIterations = PHYSICS_POSITION_ITERATIONS;
            VelcroPhysics.Settings.VelocityIterations = PHYSICS_VELOCITY_ITERATIONS;


            //World
            var world = new World(new Vector2(WORLD_GRAVITY_ZERO));


            //Ball Body
            var ball = BodyFactory.CreateCircle(
                world,
                BALL_RADIUS,
                BODY_DENSITY_PERFECT_SOLID,
                new Vector2(
                    BALL_START_POSITION_X,
                    BALL_START_POSITION_Y
                    ),
                BodyType.Dynamic
                );

            ball.LinearVelocity = new Vector2(BALL_START_VELOCITY_X, BALL_START_VELOCITY_Y);
            ball.Restitution    = BODY_RESTITUTION_PERFECT_BOUNCE;
            ball.Friction       = BODY_FRICTION_ZERO;
            ball.LinearDamping  = BODY_DAMPING_ZERO;
            ball.Mass           = BODY_MASS_ZERO;
            ball.IsBullet       = true;


            //Right Wall Body
            var wallRight = BodyFactory.CreateRectangle(
                world,
                WALL_THICKNESS,
                WORLD_HEIGHT,
                BODY_DENSITY_PERFECT_SOLID,
                new Vector2(
                    WORLD_WIDTH - (WORLD_UNIT * HALF),
                    (WORLD_HEIGHT * HALF) * INVERT
                    ),
                BODY_ROTATION_ZERO,
                BodyType.Static
                );
            bool readyToNudgeBall = true;


            //Left Wall Body
            var wallLeft = BodyFactory.CreateRectangle(
                world,
                WALL_THICKNESS,
                WORLD_HEIGHT,
                BODY_DENSITY_PERFECT_SOLID,
                new Vector2(
                    WORLD_UNIT * HALF,
                    (WORLD_HEIGHT * HALF) * INVERT
                    ),
                BODY_ROTATION_ZERO,
                BodyType.Static
                );


            //Top Wall Body
            var wallTop = BodyFactory.CreateRectangle(
                world,
                WORLD_WIDTH,
                WALL_THICKNESS,
                BODY_DENSITY_PERFECT_SOLID,
                new Vector2(
                    WORLD_WIDTH * HALF,
                    (WORLD_UNIT * HALF) * INVERT
                    ),
                BODY_ROTATION_ZERO,
                BodyType.Static
                );


            //Bottom Wall Body
            var wallBottom = BodyFactory.CreateRectangle(
                world,
                WORLD_WIDTH,
                WALL_THICKNESS,
                BODY_DENSITY_PERFECT_SOLID,
                new Vector2(
                    WORLD_WIDTH * HALF,
                    (WORLD_HEIGHT - (WORLD_UNIT * HALF)) * INVERT
                    ),
                BODY_ROTATION_ZERO,
                BodyType.Static
                );


            //Rendering Color
            Color terminalGreen = new Color(COLOR_TERMINALGREEN_R, COLOR_TERMINALGREEN_G, COLOR_TERMINALGREEN_B);


            //Ball Sprite
            var            ballShapeRadius = ball.FixtureList[0].Shape.Radius;
            CircleShape    ballSpriteRound;
            RectangleShape ballSpriteSquare;
            {
                //Round
                ballSpriteRound           = new CircleShape(ballShapeRadius * PIXELS_PER_METER_X);
                ballSpriteRound.FillColor = terminalGreen;

                //Square
                ballSpriteSquare = new RectangleShape(
                    new Vector2f(
                        ballShapeRadius * DOUBLE * PIXELS_PER_METER_X,
                        ballShapeRadius * DOUBLE * PIXELS_PER_METER_Y
                        )
                    );
                ballSpriteSquare.FillColor = terminalGreen;
            }


            //Right Wall Sprite
            var wallRightShapeWidth  = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallRight.FixtureList[0].Shape).Vertices[0].X) * DOUBLE;
            var wallRightShapeHeight = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallRight.FixtureList[0].Shape).Vertices[0].Y) * DOUBLE;
            var wallRightSprite      = new RectangleShape(
                new Vector2f(
                    wallRightShapeWidth * PIXELS_PER_METER_X,
                    wallRightShapeHeight * PIXELS_PER_METER_Y
                    )
                );

            wallRightSprite.Position = new Vector2f(
                (wallRight.Position.X - (wallRightShapeWidth * HALF)) * PIXELS_PER_METER_X,
                ((wallRight.Position.Y + (wallRightShapeHeight * HALF)) * PIXELS_PER_METER_Y) * INVERT
                );
            wallRightSprite.FillColor = terminalGreen;


            //Left Wall Sprite
            var wallLeftShapeWidth  = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallLeft.FixtureList[0].Shape).Vertices[0].X) * DOUBLE;
            var wallLeftShapeHeight = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallLeft.FixtureList[0].Shape).Vertices[0].Y) * DOUBLE;
            var wallLeftSprite      = new RectangleShape(
                new Vector2f(
                    wallLeftShapeWidth * PIXELS_PER_METER_X,
                    wallLeftShapeHeight * PIXELS_PER_METER_Y
                    )
                );

            wallLeftSprite.Position = new Vector2f(
                (wallLeft.Position.X - (wallLeftShapeWidth * HALF)) * PIXELS_PER_METER_X,
                ((wallLeft.Position.Y + (wallLeftShapeHeight * HALF)) * PIXELS_PER_METER_Y) * INVERT
                );
            wallLeftSprite.FillColor = terminalGreen;


            //Top Wall Sprite
            var wallTopShapeWidth  = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallTop.FixtureList[0].Shape).Vertices[0].X) * DOUBLE;
            var wallTopShapeHeight = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallTop.FixtureList[0].Shape).Vertices[0].Y) * DOUBLE;
            var wallTopSprite      = new RectangleShape(
                new Vector2f(
                    wallTopShapeWidth * PIXELS_PER_METER_X,
                    wallTopShapeHeight * PIXELS_PER_METER_Y
                    )
                );

            wallTopSprite.Position = new Vector2f(
                (wallTop.Position.X - (wallTopShapeWidth * HALF)) * PIXELS_PER_METER_X,
                ((wallTop.Position.Y + (wallTopShapeHeight * HALF)) * PIXELS_PER_METER_Y) * INVERT
                );
            wallTopSprite.FillColor = terminalGreen;


            //Bottom Wall Sprite
            var wallBottomShapeWidth  = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallBottom.FixtureList[0].Shape).Vertices[0].X) * DOUBLE;
            var wallBottomShapeHeight = Math.Abs(((VelcroPhysics.Collision.Shapes.PolygonShape)wallBottom.FixtureList[0].Shape).Vertices[0].Y) * DOUBLE;
            var wallBottomSprite      = new RectangleShape(
                new Vector2f(
                    wallBottomShapeWidth * PIXELS_PER_METER_X,
                    wallBottomShapeHeight * PIXELS_PER_METER_Y
                    )
                );

            wallBottomSprite.Position = new Vector2f(
                (wallBottom.Position.X - (wallBottomShapeWidth * HALF)) * PIXELS_PER_METER_X,
                ((wallBottom.Position.Y + (wallBottomShapeHeight * HALF)) * PIXELS_PER_METER_Y) * INVERT
                );
            wallBottomSprite.FillColor = terminalGreen;


            //Title Text
            Font font = new Font(TEXT_FONT_FILE);

            Text topText = new Text(TEXT_MESSAGE_TOP, font);

            topText.Color         = Color.Black;
            topText.CharacterSize = TEXT_FONT_SIZE;
            topText.Position      = new Vector2f(WORLD_UNIT * PIXELS_PER_METER_X, TEXT_MESSAGE_TOP_MARGIN);

            Text bottomText = new Text(TEXT_MESSAGE_BOTTOM, font);

            bottomText.Color         = Color.Black;
            bottomText.CharacterSize = TEXT_FONT_SIZE;
            bottomText.Position      = new Vector2f(WORLD_UNIT * PIXELS_PER_METER_X, ((WORLD_HEIGHT - WORLD_UNIT) * PIXELS_PER_METER_Y) + TEXT_MESSAGE_TOP_MARGIN);


            //Sound Effects
            var sampler = new Sound[2];

            sampler[0] = new Sound(new SoundBuffer(SAMPLE_FILE_BEEP));
            sampler[1] = new Sound(new SoundBuffer(SAMPLE_FILE_BIP));
            int soundEffectCycle = 0;

            bool readyToPlaySoundEffect = true;


            //Music
            Music synthesizer = new Music(MUSIC_FILE);

            synthesizer.Loop   = true;
            synthesizer.Volume = MUSIC_VOLUME;
            bool readyToToggleMusic = true;



            //*************
            //* Execution *
            //*************


            //Initialize Display
            var screen = new RenderWindow(new VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), SCREEN_TITLE);


            //Cue Music
            synthesizer.Play();


            //Initialize Clock
            var   clock               = new Clock();
            float deltaTime           = WORLD_TIME_ELAPSED_ZERO;
            float timeElapsedLastTick = clock.ElapsedTime.AsMilliseconds();
            float timeElapsedThisTick;


            //Enter Game Loop
            while (!Keyboard.IsKeyPressed(Keyboard.Key.Escape) && screen.IsOpen)
            {
                //Calculate Delta Time
                timeElapsedThisTick = clock.ElapsedTime.AsMilliseconds();
                deltaTime          += (timeElapsedThisTick - timeElapsedLastTick) / 1000.0f;
                timeElapsedLastTick = timeElapsedThisTick;


                //Step Physics
                while (deltaTime >= WORLD_TIME_RESOLUTION)
                {
                    //Hold 'P' to Pause Processing and Print Data
                    if (Keyboard.IsKeyPressed(Keyboard.Key.P))
                    {
                        Console.WriteLine("(" + ball.Position.X + "," + ball.Position.Y + ") (" + ball.LinearVelocity.X + "," + ball.LinearVelocity.Y + ")");
                        while (Keyboard.IsKeyPressed(Keyboard.Key.P))
                        {
                        }
                        clock.Restart();
                        timeElapsedLastTick = clock.ElapsedTime.AsMilliseconds();
                    }

                    //Hold 'S' to Slow Processing and Print Data
                    if (Keyboard.IsKeyPressed(Keyboard.Key.S))
                    {
                        world.Step(WORLD_TIME_RESOLUTION / WORLD_SLOW_MOTION_FACTOR);
                        Console.WriteLine("(" + ball.Position.X + "," + ball.Position.Y + ") (" + ball.LinearVelocity.X + "," + ball.LinearVelocity.Y + ")");
                    }
                    else
                    {
                        world.Step(WORLD_TIME_RESOLUTION);
                    }

                    deltaTime -= WORLD_TIME_RESOLUTION;
                }


                //Hold 'C' to Render Round Ball Sprite
                Shape ballSprite = Keyboard.IsKeyPressed(Keyboard.Key.C) ? (Shape)ballSpriteRound : (Shape)ballSpriteSquare;


                //Press Arrow Keys to Nudge Ball
                if (Keyboard.IsKeyPressed(Keyboard.Key.Up) ||
                    Keyboard.IsKeyPressed(Keyboard.Key.Down) ||
                    Keyboard.IsKeyPressed(Keyboard.Key.Left) ||
                    Keyboard.IsKeyPressed(Keyboard.Key.Right))
                {
                    readyToNudgeBall = false;

                    Vector2 nudgedVelocity = ball.LinearVelocity;

                    if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                    {
                        nudgedVelocity = new Vector2(nudgedVelocity.X, nudgedVelocity.Y + BALL_NUDGE_AMOUNT);
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Down))
                    {
                        nudgedVelocity = new Vector2(nudgedVelocity.X, nudgedVelocity.Y - BALL_NUDGE_AMOUNT);
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Left))
                    {
                        nudgedVelocity = new Vector2(nudgedVelocity.X - BALL_NUDGE_AMOUNT, nudgedVelocity.Y);
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Right))
                    {
                        nudgedVelocity = new Vector2(nudgedVelocity.X + BALL_NUDGE_AMOUNT, nudgedVelocity.Y);
                    }

                    ball.LinearVelocity = nudgedVelocity;
                }
                else
                {
                    readyToNudgeBall = true;
                }


                //Press 'M' to Toggle Music
                if (Keyboard.IsKeyPressed(Keyboard.Key.M))
                {
                    if (readyToToggleMusic)
                    {
                        readyToToggleMusic = false;
                        if (synthesizer.Status == SoundStatus.Playing)
                        {
                            synthesizer.Stop();
                        }
                        else
                        {
                            synthesizer.Play();
                        }
                    }
                }
                else
                {
                    readyToToggleMusic = true;
                }


                //Update Ball Sprite Position
                ballSprite.Position = new Vector2f(
                    (int)((ball.Position.X - ball.FixtureList[0].Shape.Radius) * PIXELS_PER_METER_X),
                    ((int)((ball.Position.Y + ball.FixtureList[0].Shape.Radius) * PIXELS_PER_METER_Y)) * INVERT
                    );


                //Render Screen
                screen.Clear(Color.Black);

                screen.Draw(wallRightSprite);
                screen.Draw(wallLeftSprite);
                screen.Draw(wallTopSprite);
                screen.Draw(wallBottomSprite);
                screen.Draw(ballSprite);
                screen.Draw(topText);
                screen.Draw(bottomText);

                screen.DispatchEvents();
                screen.Display();


                //Play Sound Effect for Current Collision
                if (ball.ContactList != null)
                {
                    if (readyToPlaySoundEffect)
                    {
                        readyToPlaySoundEffect = false;
                        sampler[soundEffectCycle].Play();
                        soundEffectCycle = (soundEffectCycle + 1) % sampler.Length;
                    }
                }
                else
                {
                    readyToPlaySoundEffect = true;
                }
            }
        }
Example #11
0
        public void Run()
        {
            // Spawn our initial populaiton of individuals
            world.Spawn();

            Thread.Sleep(3000);

            // Set our generation count to zero and restart our timer
            int generation = 0;

            generationClock.Restart();

            while (window.IsOpen)
            {
                // Get the amount of time that has passed since we drew the last frame.
                float deltaT = clock.Restart().AsMicroseconds() / 1000000f;

                // Clear the previous frame
                window.Clear(Configuration.Background);

                // Process events
                window.DispatchEvents();

                // Camera movement is now separate from our other screen update code to minimise overhead.
                screenManager.UpdateCamera(deltaT);

                screenManager.Draw(deltaT);

                // Update the window
                window.Display();

                // If one second has passed, breed the next generation
                if (generationClock.ElapsedTime.AsSeconds() > generationTime &&
                    (doGeneration?.IsCompleted ?? true) &&
                    !world.HasConverged)
                {
                    doGeneration = Task.Run(() =>
                    {
                        // Do one generation of breeding & culling.
                        world.DoGeneration();

                        // Restart our generation timer
                        generationClock.Restart();

                        // Update the screen to show the new generation
                        pathScreen.GenerationString.StringText = $"Generation: {++generation}";

                        // Draw the paths of the current best individual
                        pathScreen.UpdateSequence(world.GetBestIndividual());

                        // Update all the screen components that are unrelated to our sequence.
                        screenManager.Update(deltaT);
                    });
                }

                // Our GA has either hit the max generations or has stopped improving, set the GA as complete
                // and copy the history of fitness values to the clipboard
                if (world.GenerationCount == GAConfig.MaxGenerations ||
                    world.NoImprovementCount == GAConfig.MaxNoImprovementCount)
                {
                    pathScreen.SetGACompleted();

                    // Copy the fitness to clipboard
                    Clipboard.SetText(string.Join(",", world.FitnessOverTime));
                }

                // Process any key presses that the user has made.
                this.ProcessUserInput();

                // Check to see if the user wants to stop the simulation.
                if (Keyboard.IsKeyPressed(Configuration.QuitKey) ||
                    Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                {
                    return;
                }
            }
        }
Example #12
0
        /// <summary>
        /// <code>
        /// if (Info.Pressed)
        /// {
        ///   Thread.Sleep(150);
        ///   Info.Pressed = false;
        /// }
        /// </code>
        /// Everytime we press a button, we would like to change it's color, but also
        /// we would like to remain for some time in a current window, so we can see that the
        /// color of the button has changed. We can do this by making the thread sleep.
        /// </summary>
        public void Run()
        {
            _inputState = new InputState();

            _window = new RenderWindow(new VideoMode(800, 800), "Zombie Survival", Styles.Default, new ContextSettings(24, 8, 2));
            _window.SetFramerateLimit(100);
            _window.SetVerticalSyncEnabled(true);
            _window.SetActive(false);


            // Setup event handlers
            _window.Closed              += OnClosed;
            _window.KeyPressed          += OnKeyPressed;
            _window.KeyReleased         += OnKeyReleased;
            _window.MouseMoved          += OnMouseMoved;
            _window.MouseButtonPressed  += OnMouseButtonPressed;
            _window.MouseButtonReleased += OnMouseButtonReleased;
            _window.MouseWheelMoved     += OnMouseWheel;

            if (!File.Exists("../../../../score"))
            {
                File.Create("../../../../score").Close();
            }

            InitMenu();
            InitScore();
            InitInfo();
            InitSetName();

            float lastTime = 0f;

            while (_window.IsOpen)
            {
                float currentTime = GameWorld.Watch.ElapsedMilliseconds;
                float deltaTime   = currentTime - lastTime;
                lastTime = currentTime;

                _window.DispatchEvents();

                switch (_mode)
                {
                case Mode.Closing:
                    _window.Close();
                    break;

                case Mode.SetName:
                    SetName.Update(deltaTime, _window, _inputState, ref _mode);
                    _window.Clear(Color.Black);
                    SetName.Draw(_window);
                    break;

                case Mode.Menu:
                    Menu.Update(deltaTime, _inputState, _window, ref _mode);
                    _window.Clear(Color.Black);
                    Menu.Draw(_window);
                    break;

                case Mode.Score:
                    Score.Update(deltaTime, _window, _inputState, ref _mode);
                    _window.Clear(Color.Black);
                    Score.Draw(_window);
                    break;

                case Mode.Info:
                    Info.Update(deltaTime, _window, _inputState, ref _mode);
                    _window.Clear(Color.Black);
                    Info.Draw(_window);
                    break;

                case Mode.Game:
                    GameWorld.Update(deltaTime, _inputState, _window);
                    _window.Clear(Color.White);
                    GameWorld.Draw(_window);
                    if (GameWorld.Player1.Dead)
                    {
                        _mode = Mode.Menu;
                        WriteResult(GameWorld.Player1.Name, GameWorld.Player1.Score);
                    }
                    break;
                }

                if (!_window.IsOpen)
                {
                    break;
                }

                _window.Display();

                if (Info.Pressed)
                {
                    Thread.Sleep(150);
                    Info.Pressed = false;
                }

                if (Score.Pressed)
                {
                    Thread.Sleep(150);
                    Score.Pressed = false;
                }

                if (SetName.Pressed)
                {
                    Thread.Sleep(150);
                    GameWorld.Player1.Name = SetName.InputText.DisplayedString;
                    SetName.Pressed        = false;
                }

                if (Menu.Pressed)
                {
                    Thread.Sleep(150);
                    Menu.Pressed = false;
                }
            }
        }
Example #13
0
        static void Main(string[] args)
        {
            var window = new RenderWindow(new VideoMode(1920, 1080), "Cookie clicker", Styles.Default);

            window.SetFramerateLimit(60);
            Cookie        cookie        = new Cookie();
            GameInterface gameInterface = new GameInterface();

            #region events
            window.Closed              += (s, a) => window.Close();
            window.MouseButtonPressed  += (s, a) => cookie.isInside(a.X, a.Y);
            window.MouseButtonReleased += (s, a) => cookie.isInside2(a.X, a.Y);
            window.MouseButtonPressed  += (s, a) => gameInterface.isInside(a.X, a.Y, ref cookie.cookies);
            #endregion

            //Game loop
            while (window.IsOpen)
            {
                window.DispatchEvents();
                window.Clear();
                draw();
                convertDataToString();

                #region game time
                gameInterface.frameCounter++;
                if (gameInterface.frameCounter == 60)
                {
                    gameInterface.gameTime++;
                    cookie.cookies += gameInterface.cookiesPerSec;

                    gameInterface.frameCounter = 0;
                }
                #endregion

                Console.WriteLine(gameInterface.gameTime);

                window.Display();
            }

            void draw()
            {
                window.Draw(cookie.cookie);
                //window.Draw(gameInterface.timer);

                window.Draw(gameInterface.cookieAmount);
                window.Draw(gameInterface.cookieCounter);
                window.Draw(gameInterface.perSec);
                window.Draw(gameInterface.perSecAmount);

                window.Draw(gameInterface.ClickBooster);
                window.Draw(gameInterface.ClickBooster1);
                window.Draw(gameInterface.ClickBooster2);
                window.Draw(gameInterface.ClickBooster3);
                window.Draw(gameInterface.ClickBooster4);
                window.Draw(gameInterface.ClickBooster5);

                window.Draw(gameInterface.boost);
                window.Draw(gameInterface.boost1);
                window.Draw(gameInterface.boost2);
                window.Draw(gameInterface.boost3);
                window.Draw(gameInterface.boost4);
                window.Draw(gameInterface.boost5);

                window.Draw(gameInterface.boostamount);
                window.Draw(gameInterface.boost1amount);
                window.Draw(gameInterface.boost2amount);
                window.Draw(gameInterface.boost3amount);
                window.Draw(gameInterface.boost4amount);
                window.Draw(gameInterface.boost5amount);

                window.Draw(gameInterface.boostprice);
                window.Draw(gameInterface.boost1price);
                window.Draw(gameInterface.boost2price);
                window.Draw(gameInterface.boost3price);
                window.Draw(gameInterface.boost4price);
                window.Draw(gameInterface.boost5price);
            }

            void convertDataToString()
            {
                gameInterface.cookieCounter.DisplayedString = Convert.ToString(cookie.cookies);
                gameInterface.perSecAmount.DisplayedString  = Convert.ToString(gameInterface.cookiesPerSec);

                gameInterface.boostamount.DisplayedString  = Convert.ToString(gameInterface.boost_amount);
                gameInterface.boost1amount.DisplayedString = Convert.ToString(gameInterface.boost1_amount);
                gameInterface.boost2amount.DisplayedString = Convert.ToString(gameInterface.boost2_amount);
                gameInterface.boost3amount.DisplayedString = Convert.ToString(gameInterface.boost3_amount);
                gameInterface.boost4amount.DisplayedString = Convert.ToString(gameInterface.boost4_amount);
                gameInterface.boost5amount.DisplayedString = Convert.ToString(gameInterface.boost5_amount);

                gameInterface.boostprice.DisplayedString  = Convert.ToString(gameInterface.boost_Price);
                gameInterface.boost1price.DisplayedString = Convert.ToString(gameInterface.boost1_Price);
                gameInterface.boost2price.DisplayedString = Convert.ToString(gameInterface.boost2_Price);
                gameInterface.boost3price.DisplayedString = Convert.ToString(gameInterface.boost3_Price);
                gameInterface.boost4price.DisplayedString = Convert.ToString(gameInterface.boost4_Price);
                gameInterface.boost5price.DisplayedString = Convert.ToString(gameInterface.boost5_Price);

                cookie.clickBoost = gameInterface.boost_amount;
            }
        }
Example #14
0
        public void Run()
        {
            Pole = new Pole();

            var isGravity = true;

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

                WinX = Window.Size.X;
                WinY = Window.Size.Y;

                if (Keyboard.IsKeyPressed(Keyboard.Key.Z))
                {
                    isGravity = !isGravity;
                }

                if (isGravity)
                {
                    if (Keyboard.IsKeyPressed(Keyboard.Key.A))
                    {
                        Pole.vector = 'a';
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.W))
                    {
                        Pole.vector = 'w';
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.D))
                    {
                        Pole.vector = 'd';
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.S))
                    {
                        Pole.vector = 's';
                    }

                    Pole.Update();
                }
                else
                {
                    if (Keyboard.IsKeyPressed(Keyboard.Key.A))
                    {
                        Pole.Update('a');
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.W))
                    {
                        Pole.Update('w');
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.D))
                    {
                        Pole.Update('d');
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.S))
                    {
                        Pole.Update('s');
                    }
                    else
                    {
                        Pole.Update();
                    }
                }


                Window.Clear(Color.Black);

                Window.Draw(Pole);

                Window.Display();
            }
        }
Example #15
0
        private static void UpdateDraw(RenderWindow window)
        {
            cameraPos = new Vector2f((int)clientPlayer.position.X, (int)clientPlayer.position.Y);
            camera2D  = new View(cameraPos, new Vector2f(640, 480));
            camera2D.Zoom(.5f);
            View noCamera = new View(new Vector2f(0, 0), new Vector2f(640, 480));

            window.SetView(camera2D);

            UpdateSounds();

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

            for (int i = 0; i < connectedPlayers.Count; i++)
            {
                connectedPlayers[i].connectColor = Color.White;
            }

            //window.Draw(background);
            window.Draw(basicLevelDec);


            HandleMessages();

            Text  _chatCompose = new Text(clientPlayer.textCapture, font);
            float chatScale    = .4f;

            _chatCompose.Scale    = new Vector2f(chatScale, chatScale);
            _chatCompose.Position = new Vector2f(-300, 200);// clientPlayer.position;

            Text _textConnected = new Text(connected ? "CONNECTED" : "DISCONNECTED", font);

            _textConnected.Scale    = new Vector2f(chatScale, chatScale);
            _textConnected.Position = new Vector2f(-300, -230);// clientPlayer.position;



            Text _playersConnectedText = new Text(connectedPlayers.Count + " Player Connected", font);

            _playersConnectedText.Scale    = new Vector2f(chatScale, chatScale);
            _playersConnectedText.Position = new Vector2f(-300, -220);// clientPlayer.position;



            drawPlayers();
            updatePlayers();


            window.SetView(noCamera);
            window.Draw(_chatCompose);
            window.Draw(_textConnected);
            window.Draw(_playersConnectedText);

            Color pingColor = Color.White;

            if (ping == 0)
            {
                //connected = false;
                pingColor = Color.Red;
            }
            if (ping > 100)
            {
                pingColor = Color.Yellow;
            }

            Render.drawString(font, ping + " ms", new Vector2f(-300, -240), pingColor, .4f, false);

            for (int i = 0; i < chatMessages.Count; i++)
            {
                Text chatMessage = new Text(chatMessages[i], font);
                chatMessage.Scale    = new Vector2f(chatScale, chatScale);
                chatMessage.Position = new Vector2f(-300, -200 + (i * 10));// clientPlayer.position;

                window.Draw(chatMessage);
            }



            window.Display();
        }
Example #16
0
        static void Main(string[] args)
        {
            using (var window = new RenderWindow(new VideoMode(ScreenW, ScreenH), "Asteroids"))
            {
                window.Closed += (s, e) => window.Close();
                Clock clock   = new Clock();
                Scene scene   = new Scene();
                bool  restart = true;

                Ship ship = null;

                bool spinLeft  = false,
                     spinRight = false,
                     thrust    = false,
                     brake     = false,
                     shoot     = false;
                window.KeyPressed += (s, e) =>
                {
                    switch (e.Code)
                    {
                    case Keyboard.Key.Left: spinLeft = true; break;

                    case Keyboard.Key.Right: spinRight = true; break;

                    case Keyboard.Key.Up: thrust = true; break;

                    case Keyboard.Key.Down: brake = true; break;

                    case Keyboard.Key.Space: shoot = true; break;
                    }
                };
                window.KeyReleased += (s, e) =>
                {
                    switch (e.Code)
                    {
                    case Keyboard.Key.Left: spinLeft = false; break;

                    case Keyboard.Key.Right: spinRight = false; break;

                    case Keyboard.Key.Up: thrust = false; break;

                    case Keyboard.Key.Down: brake = false; break;

                    case Keyboard.Key.Space: shoot = false; break;
                    }
                };

                while (window.IsOpen)
                {
                    window.DispatchEvents();
                    window.Clear(Color.Black);
                    float deltaTime = clock.Restart().AsSeconds();
                    if (restart)
                    {
                        scene.Clear();
                        for (int i = 0; i < 5; i++)
                        {
                            scene.Spawn(new Asteroid(3)
                            {
                                Position = new Vector2f(ScreenW, ScreenH) * 0.5f + VectorMath.Random() * ScreenH,
                                Velocity = VectorMath.Random() * 100.0f
                            });
                        }
                        ship = new Ship()
                        {
                            Position = new Vector2f(ScreenW, ScreenH) * 0.5f
                        };
                        scene.Spawn(ship);
                        restart = false;
                    }
                    else
                    {
                        if (spinLeft)
                        {
                            ship.SpinLeft(deltaTime);
                        }
                        if (spinRight)
                        {
                            ship.SpinRight(deltaTime);
                        }
                        if (thrust)
                        {
                            ship.Thrust(deltaTime);
                        }
                        if (brake)
                        {
                            ship.Brake(deltaTime);
                        }
                        if (shoot)
                        {
                            ship.Shoot(scene);
                        }
                        scene.UpdateAll(deltaTime);
                        scene.RenderAll(window);
                        restart = scene.PlayerWon || scene.PlayerLost;
                    }
                    window.Display();
                }
            }
        }
Example #17
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Create the main window
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML.Net Shader");

            window.SetVerticalSyncEnabled(true);

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

            // Load the application font and pass it to the Effect class
            Font font = new Font("resources/sansation.ttf");

            Effect.SetFont(font);

            // Create the effects
            effects = new Effect[]
            {
                new Pixelate(),
                new WaveBlur(),
                new StormBlink(),
                new Edge()
            };
            current = 0;

            // Create the messages background
            Texture textBackgroundTexture = new Texture("resources/text-background.png");
            Sprite  textBackground        = new Sprite(textBackgroundTexture);

            textBackground.Position = new Vector2f(0, 520);
            textBackground.Color    = new Color(255, 255, 255, 200);

            // Create the description text
            description           = new Text("Current effect: " + effects[current].Name, font, 20);
            description.Position  = new Vector2f(10, 530);
            description.FillColor = new Color(80, 80, 80);

            // Create the instructions text
            Text instructions = new Text("Press left and right arrows to change the current shader", font, 20);

            instructions.Position  = new Vector2f(280, 555);
            instructions.FillColor = new Color(80, 80, 80);

            // Start the game loop
            Clock clock = new Clock();

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

                // Update the current example
                float x = (float)Mouse.GetPosition(window).X / window.Size.X;
                float y = (float)Mouse.GetPosition(window).Y / window.Size.Y;
                effects[current].Update(clock.ElapsedTime.AsSeconds(), x, y);

                // Clear the window
                window.Clear(new Color(255, 128, 0));

                // Draw the current example
                window.Draw(effects[current]);

                // Draw the text
                window.Draw(textBackground);
                window.Draw(instructions);
                window.Draw(description);

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
Example #18
0
        /// <summary>
        /// When overridden in the derived class, draws the graphics to the control.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        protected override void HandleDraw(TickCount currentTime)
        {
            if (DesignMode)
            {
                base.HandleDraw(currentTime);
                return;
            }

            TransBoxManager.Update(currentTime);

            RenderWindow.Clear(Color.Black);

            // Update the cursor display for the transformation box. Only change the cursor if we are currently
            // under a transbox, or we have just stopped being under one. If we update it every frame, it screws with the
            // UI display for everything else (like when the cursor is over a textbox).
            var transBoxCursor = TransBoxManager.CurrentCursor;

            if (transBoxCursor == null)
            {
                if (_wasUnderTransBox)
                {
                    Cursor            = Cursors.Default;
                    _wasUnderTransBox = false;
                }
            }
            else
            {
                Cursor            = transBoxCursor;
                _wasUnderTransBox = true;
            }


            // TODO: Implement drawing logic
            // Do some actual work here

            _spriteBatch.Begin(BlendMode.Alpha, _camera);


            if (TilesetConfiguration != null)
            {
                int x = 0;
                int y = 0;

                for (int i = 0; i < TilesetConfiguration.GrhDatas.Count; i++)
                {
                    var grh  = TilesetConfiguration.GrhDatas[i];
                    Grh nGrh = new Grh(grh);

                    nGrh.Draw(_spriteBatch, new Vector2(y * EditorSettings.Default.GridSize.X, x * EditorSettings.Default.GridSize.Y));

                    y++;

                    if (y % TilesetConfiguration.Width == 0)
                    {
                        x++;
                        y = 0;
                    }
                }

                // Draw little selection box
                RenderRectangle.Draw(_spriteBatch, new Rectangle(grhX, grhY, EditorSettings.Default.GridSize.X, EditorSettings.Default.GridSize.Y), Color.TransparentWhite, Color.White, -3f);
            }


            _spriteBatch.End();

            int deltaTime;

            if (_lastUpdateTime == TickCount.MinValue)
            {
                deltaTime = 30;
            }
            else
            {
                deltaTime = Math.Max(5, (int)(currentTime - _lastUpdateTime));
            }

            _lastUpdateTime = currentTime;

            _camera.Min += _cameraVelocity * (deltaTime / 1000f);
        }
Example #19
0
        public DoomApplication(CommandLineArgs args)
        {
            config = new Config(ConfigUtilities.GetConfigPath());

            try
            {
                config.video_screenwidth  = Math.Clamp(config.video_screenwidth, 320, 3200);
                config.video_screenheight = Math.Clamp(config.video_screenheight, 200, 2000);
                var videoMode = new VideoMode((uint)config.video_screenwidth, (uint)config.video_screenheight);
                var style     = Styles.Close | Styles.Titlebar;
                if (config.video_fullscreen)
                {
                    style = Styles.Fullscreen;
                }
                window = new RenderWindow(videoMode, ApplicationInfo.Title, style);
                window.Clear(new Color(64, 64, 64));
                window.Display();

                if (args.deh.Present)
                {
                    DeHackEd.ReadFiles(args.deh.Value);
                }

                resource = new CommonResource(GetWadPaths(args), !args.nodeh.Present);

                renderer = new SfmlRenderer(config, window, resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    sound = new SfmlSound(config, resource.Wad);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    music = ConfigUtilities.GetSfmlMusicInstance(config, resource.Wad);
                }

                userInput = new SfmlUserInput(config, window, !args.nomouse.Present);

                events = new List <DoomEvent>();

                options             = new GameOptions();
                options.GameVersion = resource.Wad.GameVersion;
                options.GameMode    = resource.Wad.GameMode;
                options.MissionPack = resource.Wad.MissionPack;
                options.Renderer    = renderer;
                options.Sound       = sound;
                options.Music       = music;
                options.UserInput   = userInput;

                menu = new DoomMenu(this);

                opening = new OpeningSequence(resource, options);

                cmds = new TicCmd[Player.MaxPlayerCount];
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    cmds[i] = new TicCmd();
                }
                game = new DoomGame(resource, options);

                wipe   = new WipeEffect(renderer.WipeBandCount, renderer.WipeHeight);
                wiping = false;

                currentState = ApplicationState.None;
                nextState    = ApplicationState.Opening;
                needWipe     = false;

                sendPause = false;

                quit        = false;
                quitMessage = null;

                CheckGameArgs(args);

                window.Closed      += (sender, e) => window.Close();
                window.KeyPressed  += KeyPressed;
                window.KeyReleased += KeyReleased;

                if (!args.timedemo.Present)
                {
                    window.SetFramerateLimit(35);
                }

                mouseGrabbed = false;
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Example #20
0
        public static void Main(string[] args)
        {
            //Process program arguments
            ProcessArgs(args);

            // Create the main _window
            _window = new RenderWindow(new VideoMode(1280, 720), "Pixel Engine", Styles.Titlebar);
            _window.SetVerticalSyncEnabled(true);
            _window.Resized += new EventHandler <SizeEventArgs>(onResize);
            _window.Closed  += new EventHandler(OnClose);

            if (pScene.Init( ) == 0)
            {
                //Do other init stuff
            }

            //Create the main camera and hud camera
            View renderView   = new View(new FloatRect(0, 0, _window.Size.X, _window.Size.Y));
            View renderViewUI = new View(new FloatRect(0, 0, _window.Size.X, _window.Size.Y));

            //Load system resources
            LoadSystemResources( );


            //Testing DEBUG
            Gameplay.pSprite newSprite  = new Gameplay.pSprite("Resources/deleteMe.png", new IntRect(0, 0, 300, 300), new Vector2f(200, 200));
            RectangleShape   background = new RectangleShape(new Vector2f(1000, 1000));

            background.FillColor = Color.Magenta;
            background.Position  = new Vector2f(0, 0);

            //Fps stuff
            clock.Start( );
            float frames = 0;
            float fps    = 0;

            /// <Summary>
            /// INITIATE DEFAULT ENGINE SYSTEM SERVICES
            /// </summary>
            SYSTEM_SERVICES = new List <pSystemService>( );
            //SYSTEM_SERVICES.Add( new pCollisionSystem( ) );


            /*
             * Begin calls
             */
            foreach (pSystemService _sysService in SYSTEM_SERVICES)
            {
                _sysService.Begin( );
            }

            /// <Summary>
            /// ENGINE LOOP
            /// </summary>
            while (_window.IsOpen( ))
            {
                // Process events
                _window.DispatchEvents( );

                if (Keyboard.IsKeyPressed(Keyboard.Key.Tilde))
                {
                    ToggleDevMode( );
                }
                if (!Keyboard.IsKeyPressed(Keyboard.Key.Tilde))
                {
                    bCanToggle = true;
                }

                // Clear screen
                _window.Clear( );
                _window.SetView(renderView);

                /// <summary>
                /// UPDATE CALL
                /// </summary>
                foreach (pSystemService _sService in SYSTEM_SERVICES)
                {
                    if (_sService.bEnabled)
                    {
                        _sService.Update( ); //Update system services if enabled
                    }
                }

                //Debug draw collision


                /// <summary>
                /// DRAW CALLS
                /// </summary>


                /// <summary>
                /// DEBUG DEV MODE DRAWING
                /// </summary>
                if (bDevMode)
                {
                    //Camera controls
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Left))
                    {
                        renderView.Move(new Vector2f(( float )(-300 * deltaTime), 0));
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Right))
                    {
                        renderView.Move(new Vector2f(( float )(300 * deltaTime), 0));
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                    {
                        renderView.Move(new Vector2f(0, ( float )(-300 * deltaTime)));
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Down))
                    {
                        renderView.Move(new Vector2f(0, ( float )(300 * deltaTime)));
                    }

                    Text debugHelp = new Text("Dev mode Enabled! Arrow Keys - Move", systemFont, 16);
                    debugHelp.Position = new Vector2f(( int )(_window.Size.X / 2 - 100), ( int )(_window.Size.Y - 32));
                    Text fpsText        = new Text("FPS: " + fps.ToString( ), systemFont, 16);
                    Text mouseScreenPos = new Text("Mouse Screen Position: " + Mouse.GetPosition(_window).ToString( ), systemFont, 16);
                    mouseScreenPos.Position = new Vector2f(0, 16);
                    Text mouseWorldPos = new Text("Mouse World Position: " + _window.MapPixelToCoords(Mouse.GetPosition(_window)), systemFont, 16);
                    mouseWorldPos.Position = new Vector2f(0, 32);

                    //Do hud drawingngs
                    _window.SetView(renderViewUI);
                    _window.Draw(fpsText);
                    _window.Draw(mouseScreenPos);
                    _window.Draw(mouseWorldPos);
                    _window.Draw(debugHelp);
                }

                _window.Display( );
                frames++;

                //Calculate deltaTime
                _deltaTime = deltaClock.Elapsed;
                deltaClock.Restart( );
                deltaTime = _deltaTime.TotalSeconds;
                //Calculate FPS
                if (clock.Elapsed.Seconds > 0)
                {
                    fps    = frames / clock.Elapsed.Seconds;
                    frames = 0;
                    clock.Restart( );
                }
            }
        }
Example #21
0
 private void Update(double deltaTime)
 {
     Window.Clear();
     CurrentScene?.Update(deltaTime);
 }
Example #22
0
        static void Main(string[] args)
        {
            settings.AntialiasingLevel = 8;

            MainWindow = new RenderWindow(new VideoMode(WidthWindow, HeightWindow), "Story of one Cube", Styles.None, settings);
            MainWindow.SetVerticalSyncEnabled(true);
            MainWindow.Closed             += MainWindow_Closed;
            MainWindow.KeyPressed         += MainWindow_KeyPressed;
            MainWindow.KeyReleased        += MainWindow_KeyReleased;
            MainWindow.MouseMoved         += MainWindow_MouseMoved;
            MainWindow.MouseButtonPressed += MainWindow_MouseButtonPressed;

            MainWindow.SetVerticalSyncEnabled(true);

            CharacterMovesAnimation.Init();
            DeadScreen.Init(MainWindow);
            WinScreen.Init(MainWindow);
            MainMenu.Init(MainWindow);
            Background.Init(MainWindow);
            Sounds.Init();
            Musics.Init();
            Inventory.Init();
            Interface.Init();
            LevelChoosePage.Init(MainWindow);

            levelNow = new Level1();

            Background.Set(0);

            musicNow = Musics.MainMenu;
            musicNow.Play();

            while (MainWindow.IsOpen)
            {
                MainWindow.Clear();

                Background.Draw(MainWindow);

                if (Background.IsLoaded)
                {
                    if (windowModeNow == WindowMode.Menu)
                    {
                        MainMenu.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.LevelsChoose)
                    {
                        LevelChoosePage.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Game)
                    {
                        levelNow.Update(MainWindow);
                        levelNow.Draw(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Dead)
                    {
                        levelNow.Draw(MainWindow);
                        DeadScreen.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Pause)
                    {
                        levelNow.Draw(MainWindow);
                        DeadScreen.DrawAndUpdate(MainWindow);
                    }

                    if (windowModeNow == WindowMode.Win)
                    {
                        levelNow.Draw(MainWindow);
                        WinScreen.DrawAndUpdate(MainWindow);
                    }

                    MainWindow.DispatchEvents();
                }

                MainWindow.Display();
            }
        }
Example #23
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Create main window
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML.Net OpenGL", Styles.Default, new ContextSettings(32, 0));

            window.SetVerticalSyncEnabled(true);

            // Setup event handlers
            window.Closed     += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler <KeyEventArgs>(OnKeyPressed);
            window.Resized    += new EventHandler <SizeEventArgs>(OnResized);

            // Create a sprite for the background
            Sprite background = new Sprite(new Texture("resources/background.jpg"));

            // Create a text to display
            Text text = new Text("SFML / OpenGL demo", new Font("resources/sansation.ttf"));

            text.Position = new Vector2f(250.0F, 450.0F);
            text.Color    = new Color(255, 255, 255, 170);

            // Load an OpenGL texture.
            // We could directly use a sf::Texture as an OpenGL texture (with its Bind() member function),
            // but here we want more control on it (generate mipmaps, ...) so we create a new one
            int texture = 0;

            using (Image image = new Image("resources/texture.jpg"))
            {
                Gl.glGenTextures(1, out texture);
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
                Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, (int)image.Size.X, (int)image.Size.Y, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, image.Pixels);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
            }

            // Enable Z-buffer read and write
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthMask(Gl.GL_TRUE);
            Gl.glClearDepth(1.0F);

            // Setup a perspective projection
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluPerspective(90.0F, 1.0F, 1.0F, 500.0F);

            // Bind our texture
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
            Gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

            int startTime = Environment.TickCount;

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

                // Clear the window
                window.Clear();

                // Draw background
                window.PushGLStates();
                window.Draw(background);
                window.PopGLStates();

                // Activate the window before using OpenGL commands.
                // This is useless here because we have only one window which is
                // always the active one, but don't forget it if you use multiple windows
                window.SetActive();

                // Clear depth buffer
                Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT);

                // We get the position of the mouse cursor, so that we can move the box accordingly
                float x = Mouse.GetPosition(window).X * 200.0F / window.Size.X - 100.0F;
                float y = -Mouse.GetPosition(window).Y * 200.0F / window.Size.Y + 100.0F;

                // Apply some transformations
                float time = (Environment.TickCount - startTime) / 1000.0F;
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Gl.glTranslatef(x, y, -100.0F);
                Gl.glRotatef(time * 50, 1.0F, 0.0F, 0.0F);
                Gl.glRotatef(time * 30, 0.0F, 1.0F, 0.0F);
                Gl.glRotatef(time * 90, 0.0F, 0.0F, 1.0F);

                // Draw a cube
                float size = 20.0F;
                Gl.glBegin(Gl.GL_QUADS);

                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, -size);
                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, -size);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(size, size, -size);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(size, -size, -size);

                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, size);
                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, size);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(size, size, size);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(size, -size, size);

                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, -size);
                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, -size);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(-size, size, size);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(-size, -size, size);

                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(size, -size, -size);
                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(size, size, -size);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(size, size, size);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(size, -size, size);

                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, -size, size);
                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, -size);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(size, -size, -size);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(size, -size, size);

                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, size);
                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, size, -size);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(size, size, -size);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(size, size, size);

                Gl.glEnd();

                // Draw some text on top of our OpenGL object
                window.PushGLStates();
                window.Draw(text);
                window.PopGLStates();

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

            // Don't forget to destroy our texture
            Gl.glDeleteTextures(1, ref texture);
        }
Example #24
0
        public static void Main(string[] args)
        {
            var watch = new Stopwatch();

            watch.Start();
            _window = new RenderWindow(new VideoMode(1280, 720), "Toast", Styles.Default, new ContextSettings {
                AntialiasingLevel = 2
            });
            BSP bsp          = null;
            var manager      = new GameObjectManager(gob => bsp?.GetCollisions(gob.Bounds));
            var env          = new SimpleEnvironment(_window, manager);
            var windowCreate = watch.Elapsed.TotalSeconds;

            //_window.SetVerticalSyncEnabled(true);
            _window.SetFramerateLimit(60);

            var screenCenter = _window.Size / 2;

            _window.SetVisible(true);
            _window.Closed     += OnClosed;
            _window.KeyPressed += (sender, eventArgs) =>
            {
                if (eventArgs.Code == Keyboard.Key.Escape)
                {
                    _window.Close();
                }
            };
            var p = env.ObjectManager.Spawn <Player>();

            p.Initialize(new RectangleShape(new Vector2f(50f, 50f))
            {
                Texture = new Texture(@"media\magic.png")
                {
                    Smooth = true
                }, Scale = new Vector2f(4f, 4f)
            }, env, _window);
            p.Position = new Vector2f(screenCenter.X, screenCenter.Y);
            var numEnemies = 400;

            for (int i = 0; i < numEnemies; i++)
            {
                SpawnEnemy(env, new Vector2f(screenCenter.X, screenCenter.Y));
            }
            var showFps = false;

            _window.KeyPressed += (sender, eventArgs) =>
            {
                if (eventArgs.Code == Keyboard.Key.Tilde)
                {
                    showFps = !showFps;
                }
            };
            var font      = new Font(@"c:\windows\fonts\ariblk.ttf");
            var previous  = (float)watch.Elapsed.TotalSeconds;
            var lag       = 0f;
            var fpsBuffer = new Queue <float>();

            while (_window.IsOpen)
            {
                env.DebugText.Clear();
                var time = (float)watch.Elapsed.TotalSeconds;
                var dt   = time - previous;
                previous = time;
                lag     += dt;

                _window.DispatchEvents();
                _window.Clear();

                var preUpdate = watch.Elapsed.TotalSeconds;
                while (lag > env.FrameDelta)
                {
                    var objects = env.ObjectManager.Objects.ToList();
                    for (int i = 0; i < numEnemies - objects.Count(a => a is Enemy); i++)
                    {
                        SpawnEnemy(env, new Vector2f(screenCenter.X, screenCenter.Y));
                    }
                    objects = env.ObjectManager.Objects.ToList();
                    bsp     = new BSP(new HashSet <GameObjectBase>(objects), new FloatRect(0, 0, _window.Size.X, _window.Size.Y));
                    foreach (var gameObjectBase in objects)
                    {
                        gameObjectBase.Update();
                    }
                    manager.DestroyAll();
                    lag -= env.FrameDelta;
                }
                var postUpdate = watch.Elapsed.TotalSeconds;
                env.LogText($"update %: {100 * (postUpdate - preUpdate) / dt:F1}");
                env.FrameRemainder = lag;

                foreach (var gameObjectBase in env.ObjectManager.Objects)
                {
                    _window.Draw(gameObjectBase);
                }
                if (bsp != null)
                {
                    //_window.Draw(bsp);
                }
                if (showFps)
                {
                    fpsBuffer.Enqueue(1 / dt);
                    while (fpsBuffer.Count > 100)
                    {
                        fpsBuffer.Dequeue();
                    }
                    env.LogText($"fps: {fpsBuffer.Average():F1}");
                }
                _window.Draw(new Text(string.Join("\n", env.DebugText), font));
                _window.Display();
            }
        }
Example #25
0
        private static void Main()
        {
            Window = new RenderWindow(new VideoMode(WIGTH, HEIGHT), "Flopy Bird");
            Window.SetVerticalSyncEnabled(true);
            Window.Closed += close;
            Window.Clear();

            //Меню игры
            while (Window.IsOpen && Fast == null)
            {
                Window.DispatchEvents();
                Window.Clear();

                Background.DrawBack();
                Obstacle.DrawGround();
                //Bird.DrawBirdNotDrop();
                Menu.DrawMenu();

                if (Keyboard.IsKeyPressed(Keyboard.Key.Space))
                {
                    Fast = false;
                }
                if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                {
                    Fast = true;
                }

                Window.Display();
            }

            //Геймплей
            while (Window.IsOpen)
            {
                //Игра
                if (!(bool)Fast)
                {
                    Obstacle.Point.SoundBuffer = Obstacle.PointBuffer;
                    Bird.Wing.SoundBuffer      = Bird.WingBuffer;
                    Bird.SDie.SoundBuffer      = Bird.DieBuffer;

                    Bird.Pos.X = (WIGTH / 2) - (Bird.BIRD_W * 3);

                    while (Window.IsOpen && !Bird.Die)
                    {
                        Window.DispatchEvents();
                        Window.Clear();

                        Background.DrawBack();
                        Obstacle.DrawObstacle();
                        result.DrawCount(Obstacle.Count);
                        Bird.DrawBird();


                        Window.Display();
                    }
                    Bird.SDie.Play();
                }
                else
                {
                    Obstacle.Point.SoundBuffer = Obstacle.FastPointBuffer;
                    Bird.Wing.SoundBuffer      = Bird.FastWingBuffer;
                    Bird.SDie.SoundBuffer      = Bird.FastDieBuffer;

                    Bird.Pos.X = (WIGTH / 4) - (Bird.BIRD_W * 3);

                    while (Window.IsOpen && !Bird.Die)
                    {
                        Window.DispatchEvents();
                        Window.Clear();

                        Background.DrawBack();
                        Obstacle.DrawOneOstacle();
                        result.DrawCount(Obstacle.Count);
                        Bird.DrawBird();


                        Window.Display();
                    }
                    Bird.SDie.Play();
                }

                //Падение на землю
                while (Window.IsOpen && !Bird.OnGround)
                {
                    Window.DispatchEvents();
                    Window.Clear();

                    Background.DrawBack();
                    Obstacle.DrawNotMove();
                    Bird.DrawBird();

                    Window.Display();
                }

                Mode = (bool)Fast;
                Fast = null;

                //Меню результата
                while (Window.IsOpen && Fast == null)
                {
                    Window.DispatchEvents();
                    Window.Clear();

                    Background.DrawBack();
                    Obstacle.DrawNotMove();
                    Bird.DrawBird();
                    resultWin.DrawResultWindow(Obstacle.Count, Mode);

                    if (Keyboard.IsKeyPressed(Keyboard.Key.Space))
                    {
                        Fast = false;
                    }
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                    {
                        Fast = true;
                    }

                    Window.Display();
                }

                //Сброс состояния игрока и препядствий
                Bird.ClearBird();
                Obstacle.ObstacleClear();
            }
        }
Example #26
0
        static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "Checkbox", Styles.Titlebar | Styles.Close);

            window.SetFramerateLimit(60);
            window.SetVerticalSyncEnabled(true);
            window.Closed += (_, __) => window.Close();

            Checkbox checkbox = new Checkbox(window, new Vector2f(150, 150));

            checkbox.Width          = 310;
            checkbox.Height         = 310;
            checkbox.CrossThickness = 20f;

            Button button = new Button(window, checkbox.Position + new Vector2f(checkbox.Width + 5, 0), new Vector2f(100, 100));

            button.ButtonPressed += () =>
            {
                button.CenterColor = new Color((byte)new Random().Next(255), (byte)new Random().Next(255),
                                               (byte)new Random().Next(255));
            };
            button.CenterColor = Color.Blue;

            Button button2 = new Button(window, button.Position + new Vector2f(0, button.Height + 5), button.Size);

            button2.CenterColor = Color.Green;

            Button button3 = new Button(window, button2.Position + new Vector2f(0, button2.Height + 5), button2.Size);


            TextInput textInput = new TextInput(window, button.Position + new Vector2f(button.Width + 5, 0), 500, 100, new Font("Arial.ttf"));

            Slider slider = new Slider(window, textInput.Position + new Vector2f(0, textInput.Height + 5), 500, 100, 0, 100);

            Dropdown dropdown = new Dropdown(window, checkbox.Position + new Vector2f(0, checkbox.Height + 5), new Font("Arial.ttf"), 59,
                                             "Lorem Ipsum",
                                             "Lorem Larum",
                                             "Lorem Lurum",
                                             "Lorem Durum"
                                             );

            TextBox textBox = new TextBox(window, slider.Position + new Vector2f(0, slider.Height + 5), textInput.Width, textInput.Height, new Font("Arial.ttf"), (uint)Math.Round(textInput.Height * 0.75));

            textBox.Output("DURUM");
            textBox.TextColor = Color.Black;

            Graphic graphic = new Graphic(window, "background.png", textBox.Position + new Vector2f(0, textBox.Height + 5), new Vector2f(0, 0), new Vector2f(textBox.Width, textBox.Height));

            button2.ButtonPressed += () =>
            {
                graphic.StartFlashing((long)(1 + 10 * slider.Value));
            };

            button3.ButtonPressed += () =>
            {
                graphic.StopFlashing();
            };

            RadioButton radioButton = new RadioButton(window, textInput.Position + new Vector2f(textInput.Width + 25, 0), 50, new Vector2f(0, 157), 3);

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

                window.Clear();

                checkbox.Draw();
                button.Draw();
                textInput.Draw();
                slider.Draw();
                textInput.SetText(slider.Value.ToString());
                dropdown.Draw();
                textBox.Draw();
                graphic.Draw();
                button2.Draw();
                button3.Draw();
                radioButton.Draw();

                window.Display();
            }
        }
Example #27
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.Write(
                    "Usage: CHIP.NET PROGRAM_PATH\n" +
                    "Note: Some ROMs require compatibilty flags. Compatibility flags:\n" +
                    " --load_store\n" +
                    " --shift\n"
                    );
                return;
            }
            //tone.RepeatSpeed = 5;
            RenderWindow window = new RenderWindow(new VideoMode(64 * 10, 32 * 10), "CHIP.NET");


            Texture icon = new Texture("./icon.png");

            window.SetIcon(icon.Size.X, icon.Size.Y, icon.CopyToImage().Pixels);

            //window.SetIcon(64, 64, File.ReadAllBytes("./icon.png"));
            window.Closed      += new EventHandler(OnClose);
            window.KeyPressed  += new EventHandler <KeyEventArgs>(OnKeyPressed);
            window.KeyReleased += new EventHandler <KeyEventArgs>(OnKeyReleased);

            keymap = new Dictionary <Keyboard.Key, byte>();

            keymap.Add(Keyboard.Key.Num1, 0x1);
            keymap.Add(Keyboard.Key.Num2, 0x2);
            keymap.Add(Keyboard.Key.Num3, 0x3);
            keymap.Add(Keyboard.Key.Num4, 0xC);

            keymap.Add(Keyboard.Key.Q, 0x4);
            keymap.Add(Keyboard.Key.W, 0x5);
            keymap.Add(Keyboard.Key.E, 0x6);
            keymap.Add(Keyboard.Key.R, 0xD);

            keymap.Add(Keyboard.Key.A, 0x7);
            keymap.Add(Keyboard.Key.S, 0x8);
            keymap.Add(Keyboard.Key.D, 0x9);
            keymap.Add(Keyboard.Key.F, 0xE);

            keymap.Add(Keyboard.Key.Z, 0xA);
            keymap.Add(Keyboard.Key.X, 0x0);
            keymap.Add(Keyboard.Key.C, 0xB);
            keymap.Add(Keyboard.Key.V, 0xF);

            emulator = new Emulator(File.ReadAllBytes(args[0]), File.ReadAllBytes("./font.bin"));
            for (int i = 1; i < args.Length; i++)
            {
                CompatibilitySettings compat = CompatibilitySettings.LOAD_STORE;
                bool unknown = false;
                switch (args[i])
                {
                case "--load_store":
                    compat = CompatibilitySettings.LOAD_STORE;
                    break;

                case "--shift":
                    compat = CompatibilitySettings.SHIFT;
                    break;

                default:
                    unknown = true;
                    break;
                }
                if (unknown)
                {
                    Console.WriteLine("Unknown flag " + args[i]);
                }
                else
                {
                    emulator.EnableCompat(compat);
                    Console.WriteLine("Enabled " + args[i]);
                }
            }
            Color OffColor = new Color(143, 145, 133);
            Color OnColor  = new Color(17, 29, 43);

            window.SetActive();
            //window.SetFramerateLimit(1);
            Stopwatch deltaTimer = new Stopwatch();

            deltaTimer.Start();
            //beep.Play();
            RectangleShape pixel = new RectangleShape();

            pixel.FillColor = OnColor;
            while (window.IsOpen)
            {
                window.Clear(OffColor);
                window.DispatchEvents();
                if (!done && deltaTimer.ElapsedMilliseconds > 1000 / 500)
                {
                    deltaTimer.Stop();
                    done = emulator.Step(keyInput, (int)deltaTimer.ElapsedMilliseconds);
                    if (emulator.beepFlag)
                    {
                        emulator.beepFlag = false;
                        beep.Play();
                    }
                    deltaTimer.Restart();
                }

                bool[,] gfx = emulator.GetScreen();
                //gfx[0, 31] = true;
                int gfxWidth  = gfx.GetLength(0);
                int gfxHeight = gfx.GetLength(1);

                pixel.Size = new SFML.System.Vector2f(window.DefaultView.Size.X / (float)gfxWidth, window.DefaultView.Size.Y / (float)gfxHeight);

                for (int x = 0; x < gfxWidth; x++)
                {
                    for (int y = 0; y < gfxHeight; y++)
                    {
                        if (gfx[x, y])
                        {
                            pixel.Position = new SFML.System.Vector2f(x * pixel.Size.X, y * pixel.Size.Y);
                            window.Draw(pixel);
                        }
                    }
                }

                window.Display();
            }
        }
        public DoomApplication(CommandLineArgs args, String[] configLines, HttpClient http, Stream wadStream,
                               IJSRuntime jsRuntime, IJSInProcessRuntime jSInProcessRuntime, WebAssemblyJSRuntime webAssemblyJSRuntime,
                               string wadUrl)
        {
            Http                 = http;
            WadStream            = wadStream;
            JsRuntime            = jsRuntime;
            JSInProcessRuntime   = jSInProcessRuntime;
            WebAssemblyJSRuntime = webAssemblyJSRuntime;
            configLines          = new string[] {
                "video_screenwidth=320",
                "video_screenHeight=200",
            };
            config = new Config(configLines);

            try
            {
                config.video_screenwidth  = Math.Clamp(config.video_screenwidth, 320, 3200);
                config.video_screenheight = Math.Clamp(config.video_screenheight, 200, 2000);
                var videoMode = VideoMode.CanvasMode;
                var style     = Styles.Close | Styles.Titlebar;
                if (config.video_fullscreen)
                {
                    style = Styles.Fullscreen;
                }
                window = new RenderWindow(videoMode, ApplicationInfo.Title, style);
                window.Clear(new Color(64, 64, 64));
                window.Display();

                if (args.deh.Present)
                {
                    DeHackEd.ReadFiles(args.deh.Value);
                }

                // resource = new CommonResource(GetWadPaths(args));
                resource = new CommonResource(new string[] { wadUrl });

                renderer = new SfmlRenderer(config, window, resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    sound = new SfmlSound(config, resource.Wad);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    music = ConfigUtilities.GetSfmlMusicInstance(config, resource.Wad);
                }

                userInput = new SfmlUserInput(config, window, !args.nomouse.Present);



                options             = new GameOptions();
                options.GameVersion = resource.Wad.GameVersion;
                options.GameMode    = resource.Wad.GameMode;
                options.MissionPack = resource.Wad.MissionPack;
                options.Renderer    = renderer;
                options.Sound       = sound;
                options.Music       = music;
                options.UserInput   = userInput;

                menu = new DoomMenu(this);

                opening = new OpeningSequence(resource, options);

                cmds = new TicCmd[Player.MaxPlayerCount];
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    cmds[i] = new TicCmd();
                }
                game = new DoomGame(resource, options);

                wipe   = new WipeEffect(renderer.WipeBandCount, renderer.WipeHeight);
                wiping = false;

                currentState = ApplicationState.None;
                nextState    = ApplicationState.Opening;
                needWipe     = false;

                sendPause = false;

                quit        = false;
                quitMessage = null;

                CheckGameArgs(args);
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Example #29
0
        /// <summary>
        /// Begins drawing the graphical user interface, which is not affected by the camera.
        /// </summary>
        /// <param name="clearBuffer">When true, the buffer will be cleared before drawing. When false, the contents of the previous
        /// frame will remain in the buffer, only if the last draw was also to the GUI. When the last draw call was to the
        /// world, then this will have no affect. Useful for when you want to draw multiple GUI screens on top of one another.</param>
        /// <returns>
        /// The <see cref="ISpriteBatch"/> to use to draw the GUI, or null if an unexpected
        /// error was encountered when preparing the <see cref="ISpriteBatch"/>. When null, all drawing
        /// should be aborted completely instead of trying to draw with a different <see cref="ISpriteBatch"/>
        /// or manually recovering the error.
        /// </returns>
        /// <exception cref="InvalidOperationException"><see cref="IDrawingManager.State"/> is not equal to
        /// <see cref="DrawingManagerState.Idle"/>.</exception>
        public ISpriteBatch BeginDrawGUI(bool clearBuffer = true)
        {
            if (State != DrawingManagerState.Idle)
            {
                throw new InvalidOperationException("This method cannot be called while already busy drawing.");
            }

            try
            {
                // Ensure the RenderWindow is available
                if (!IsRenderWindowAvailable())
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Skipping BeginDrawGUI() call - the RenderWindow is not available.");
                    }
                    _state = DrawingManagerState.Idle;
                    return(null);
                }

                if (clearBuffer)
                {
                    // If the last draw was also to the GUI, clear the screen
                    if (!_lastDrawWasToWorld)
                    {
                        _rw.Clear(BackgroundColor);
                    }
                }

                _lastDrawWasToWorld = false;

                // Ensure the buffer is set up
                _buffer          = _rw.CreateBufferRenderImage(_buffer);
                _sb.RenderTarget = _buffer;

                if (_buffer == null)
                {
                    return(null);
                }

                // Always clear the GUI with alpha = 0 since we will be copying it over the screen
                _buffer.Clear(_clearGUIBufferColor);

                // Start up the SpriteBatch
                _sb.Begin(BlendMode.Alpha);

                // Change the state
                _state = DrawingManagerState.DrawingGUI;
            }
            catch (AccessViolationException ex)
            {
                // More frequent and less concerning exception
                const string errmsg = "Failed to start drawing GUI on `{0}`. Device was probably lost. Exception: {1}";
                if (log.IsInfoEnabled)
                {
                    log.InfoFormat(errmsg, this, ex);
                }
                _state = DrawingManagerState.Idle;
                SafeEndSpriteBatch(_sb);
                return(null);
            }
            catch (Exception ex)
            {
                // Unexpected exception
                const string errmsg = "Failed to start drawing GUI on `{0}` due to unexpected exception. Exception: {1}";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, this, ex);
                }
                Debug.Fail(string.Format(errmsg, this, ex));
                _state = DrawingManagerState.Idle;
                SafeEndSpriteBatch(_sb);
                return(null);
            }

            return(_sb);
        }
Example #30
0
        public void OnRender()
        {
            _surface.Clear(new Color(100, 150, 200, 255));

            // Draws obstacles
            foreach (DrawableLine obstacle in Simulation.Obstacles)
            {
                obstacle.Draw(_surface, RenderStates.Default);
            }

            // Draws the trajectory and the point cloud from a robot file
            if (RobotFile.Loaded)
            {
                if (robotFileTrajectoryCheckBox.Checked)
                {
                    foreach (TrajectoryPoint trajectoryPoint in RobotFile.Trajectory.Points)
                    {
                        trajectoryPoint.Draw(_surface, RenderStates.Default);
                    }
                }

                if (robotFilePointCloudCheckBox.Checked)
                {
                    foreach (CloudPoint cloudPoint in RobotFile.PointCloud.Points)
                    {
                        cloudPoint.Draw(_surface, RenderStates.Default);
                    }
                }
            }

            // Draws the robot's trajectory
            if (robotTrajectoryCheckBox.Checked)
            {
                foreach (TrajectoryPoint trajectoryPoint in Simulation.Robot.Trajectory.Points)
                {
                    trajectoryPoint.Draw(_surface, RenderStates.Default);
                }
            }

            // Draws the robot's point cloud
            if (robotPointCloudCheckBox.Checked)
            {
                foreach (CloudPoint cloudPoint in Simulation.Robot.PointCloud.Points)
                {
                    cloudPoint.Draw(_surface, RenderStates.Default);
                }
            }

            // Draws the robot
            Simulation.Robot.Draw(_surface, RenderStates.Default);

            // Draws the robot's sensors
            if (sensorsCheckBox.Checked)
            {
                foreach (Sensor sensor in Simulation.Robot.Sensors)
                {
                    sensor.Draw(_surface, RenderStates.Default);
                }
            }

            // Draws the wheel's text
            if (wheelsCheckBox.Checked)
            {
                Simulation.Robot.LeftWheel.Text.Draw(_surface, RenderStates.Default);
                Simulation.Robot.RightWheel.Text.Draw(_surface, RenderStates.Default);
            }

            _surface.Display();
        }