Zoom() public method

Resize the view rectangle to simulate a zoom / unzoom effect
public Zoom ( float factor ) : void
factor float Zoom factor to apply, relative to the current zoom
return void
Exemplo n.º 1
0
        static void OnKeyPressed(object sender, KeyEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;

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

            if (Keyboard.IsKeyPressed(Keyboard.Key.Add))
            {
                v.Zoom(0.75f);
            }
            if (Keyboard.IsKeyPressed(Keyboard.Key.Subtract))
            {
                v.Zoom(1.25f);
            }

            if (Keyboard.IsKeyPressed(Keyboard.Key.Return))
            {
                conf.Speed += 50;
            }
            if (Keyboard.IsKeyPressed(Keyboard.Key.Space) && conf.Speed - 50 > 0)
            {
                conf.Speed -= 50;
            }

            window.SetView(v);
        }
Exemplo n.º 2
0
 public override void Init(Entity entity)
 {
     base.Init(entity);
     camera = new View(Target.Transform.Position, Global.Screen);
     camera.Zoom(2f);
     //camera.Rotate(45f);
 }
Exemplo n.º 3
0
        void SfmlControl_Resize(object sender, EventArgs e)
        {
            Vector2f size = new Vector2f(1920f, 1080f);

            SFML.Graphics.View v = new SFML.Graphics.View(m_currentViewPosition, size);
            v.Zoom(m_currentZoom);

            float windowRatio = (float)this.Size.Width / (float)this.Size.Height;
            float viewRatio   = 16f / 9f;
            float sizeX       = 1f;
            float sizeY       = 1f;
            float posX        = 0f;
            float posY        = 0f;

            bool horizontalSpacing = (windowRatio > viewRatio);

            if (horizontalSpacing)
            {
                sizeX = viewRatio / windowRatio;
                posX  = (1f - sizeX) / 2f;
            }
            else
            {
                sizeY = windowRatio / viewRatio;
                posY  = (1f - sizeY) / 2f;
            }
            v.Viewport = new FloatRect(posX, posY, sizeX, sizeY);

            m_renderWindow.SetView(v);
        }
Exemplo n.º 4
0
        public void Initialize()
        {
            world = (LayeredWorld)WorldManager.Worlds["first_world"];

            view = new View(new Vector2f(100, 0), new Vector2f(50, 50));
            view.Zoom(10);

            player = new Player(world.PlayerStartPosition);

            Program.RenderWindow.KeyPressed += RenderWindow_KeyPressed;
        }
Exemplo n.º 5
0
        private void Window_MouseWheelScrolled(object sender, MouseWheelScrollEventArgs e)
        {
            /* Método chamado quando a roda do mouse é ativada */

            // Caso seja ativado no menu move o menu para baixo e para cima
            if (Mouse.GetPosition(window).X >= window.Size.X * Informacoes.propViewMundo)
            {
                if (e.Delta == 1 && coordViewMenu.Y >= yViewMenuInicial)
                {
                    coordViewMenu.Y -= velViewMenu * deltatime;
                    viewMenu.Center  = coordViewMenu;
                    menu.AtualizarPosicaoBackground(-velViewMenu * deltatime);
                }
                else if (e.Delta == -1)
                {
                    coordViewMenu.Y += velViewMenu * deltatime;
                    viewMenu.Center  = coordViewMenu;
                    menu.AtualizarPosicaoBackground(velViewMenu * deltatime);
                }
            }

            // Caso seja ativado no mundo aplica mais ou menos zoom no mundo
            else
            {
                if (e.Delta == 1)
                {
                    viewMundo.Zoom(0.9f);
                    zoom++;
                }

                else if (e.Delta == -1)
                {
                    viewMundo.Zoom(1.1f);
                    zoom--;
                }
            }
        }
Exemplo n.º 6
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            float deltaTime = clock.Restart().AsSeconds();

            time += deltaTime;

            if (time >= 1)
            {
                Title = initialTitle + " " + ((uint)(1 / deltaTime)).ToString() + " FPS";
                time  = 0;
            }

            surface.DispatchEvents();

            robot.UpdatePointCloud(obstacles);
            robot.Update(deltaTime);

            var updateView = new SFML.Graphics.View(robot.Position, (Vector2f)surface.Size);

            updateView.Zoom(Zoom);
            surface.SetView(updateView);

            surface.Clear();
            surface.Draw(simulationGrid);

            foreach (var obstacle in obstacles)
            {
                surface.Draw(obstacle.ToArray(), PrimitiveType.LineStrip);
            }

            foreach (var trajectoryCirlce in robot.Trajectory)
            {
                surface.Draw(trajectoryCirlce);

                foreach (var impactCircle in trajectoryCirlce.ImpactCircles)
                {
                    surface.Draw(impactCircle);
                }
            }

            foreach (var sensor in robot.Sensors)
            {
                surface.Draw(sensor);
            }

            surface.Draw(robot);
            surface.Display();
        }
Exemplo n.º 7
0
        public void draw(RenderWindow win, View view)
        {
            if (resetView)
            {
                view.Center = Vector2.Zero;
                view.Zoom(100F / view.Size.Y);
                resetView = false;
            }
            win.Draw(bg);

            Map.Draw(win);
            AlignmentManager.Draw(win);
            ParticleManager.Draw(win);
            EnemyManager.Draw(win);
            Player.Draw(win);
        }
Exemplo n.º 8
0
        private void UpdateCamera()
        {
            SFML.Graphics.View view = RendWind.DefaultView;
            //centrowanie kamery
            Vector2f center = new Vector2f(0, 0);

            foreach (var item in wierzcholkiList)
            {
                center += item.Position;
            }
            center     /= wierzcholkiList.Count;
            view.Center = center;
            //zoomowanie kamery
            Vector2f maxxy = new Vector2f(0, 0);

            for (int i = 0; i < wierzcholkiList.Count; i++)
            {
                Vector2f n = wierzcholkiList[i].Position - center;
                n = new Vector2f(Math.Abs(n.X), Math.Abs(n.Y));
                if (n.X > maxxy.X)
                {
                    maxxy.X = n.X;
                }
                if (n.Y > maxxy.Y)
                {
                    maxxy.Y = n.Y;
                }
            }
            maxxy += new Vector2f(40, 40);
            maxxy *= 2;
            float zoomfactor = (maxxy.X > maxxy.Y) ? maxxy.X / view.Size.X : maxxy.Y / view.Size.Y;

            view.Zoom(zoomfactor);

            RendWind.SetView(view);
        }
Exemplo n.º 9
0
        void RefreshView()
        {
            View v = new View(new FloatRect(cameraX, cameraY, Width, Height));

            v.Rotation = -cameraAngle;
            v.Zoom(1 / cameraZoom);
            RenderTarget.SetView(v);
        }
Exemplo n.º 10
0
        void SfmlControl_Resize(object sender, EventArgs e)
        {
            Vector2f size = new Vector2f(1920f, 1080f);
            SFML.Graphics.View v = new SFML.Graphics.View(m_currentViewPosition, size);
            v.Zoom(m_currentZoom);

            float windowRatio = (float)this.Size.Width / (float)this.Size.Height;
            float viewRatio = 16f / 9f;
            float sizeX = 1f;
            float sizeY = 1f;
            float posX = 0f;
            float posY = 0f;

            bool horizontalSpacing = (windowRatio > viewRatio);

            if (horizontalSpacing)
            {
                sizeX = viewRatio / windowRatio;
                posX = (1f - sizeX) / 2f;
            }
            else
            {
                sizeY = windowRatio / viewRatio;
                posY = (1f - sizeY) / 2f;
            }
            v.Viewport = new FloatRect(posX, posY, sizeX, sizeY);

            m_renderWindow.SetView(v);
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
0
 public CameraManager(Game game)
 {
     _game = game;
     _worldView = new View(new Vector2f(0, 0), new Vector2f(800, 600));
     _worldView.Zoom(1f / 32f);
 }
Exemplo n.º 13
0
 public CameraSystem()
 {
     _worldView = new View(new Vector2f(0, 0), new Vector2f(Game.window.DefaultView.Size.X, Game.window.DefaultView.Size.Y));
     _worldView.Zoom(1f / ORIGINAL_SCALE);
 }