Ejemplo n.º 1
0
        public void resetCamera()
        {
            if (!Constants.FULLSCREEN)
            {
                cam = new Camera2d(Constants.GAME_WORLD_WIDTH, Constants.GAME_WORLD_HEIGHT);
                cam.Pos = new Vector2(Constants.GAME_WORLD_WIDTH * 0.5f, Constants.GAME_WORLD_HEIGHT * 0.6f);

            }
            else
            {
                cam = new Camera2d(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
                //if (game.gMode != 6)
                    cam.Pos = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * 0.5f, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * 0.6f);
               // else
                   // cam.Pos = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * 1, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * 0.2f);

            }
            //cam.Pos = startingCamPosition;

            cam.Zoom = 0.55f * zoomRatio;

            if (game.camZoomValue != -1)
            {
                cam.Zoom = game.camZoomValue;
                cam.Pos = game.camPosSet;
            }
        }
Ejemplo n.º 2
0
        public void initialize()
        {
            //effect = new BasicEffect(gdm.GraphicsDevice);
            //effect.Projection = Matrix.CreateOrthographicOffCenter(0, gdm.GraphicsDevice.Viewport.Width, gdm.GraphicsDevice.Viewport.Height, 0, -1, 1);
            //effect.VertexColorEnabled = true;

            spriteBatch = new SpriteBatch(gdm.GraphicsDevice);

            ActualScreenPixelWidth = gdm.GraphicsDevice.Viewport.Width;
            ActualScreenPixelHeight = gdm.GraphicsDevice.Viewport.Height;
            ScreenAspectRatio = (float)ActualScreenPixelWidth / (float)ActualScreenPixelHeight;

            if (ActualScreenPixelWidth != Constants.DESIRED_GAME_RESOLUTION_WIDTH || ActualScreenPixelHeight != Constants.DESIRED_GAME_RESOLUTION_HEIGHT)
            {
                Console.WriteLine("Could not get desired resolution of " + Constants.DESIRED_GAME_RESOLUTION_WIDTH + "x"
                    + Constants.DESIRED_GAME_RESOLUTION_HEIGHT + ". Using " + ActualScreenPixelWidth + "x" + ActualScreenPixelHeight + ".");
            }
            calculateRenderingArea();

            GameToScreen = RenderingAreaWidth / Constants.GAME_WORLD_WIDTH;
            ScreenToGame = 1 / GameToScreen;
            float h = 1;
            float w = 1;
            if (!Constants.FULLSCREEN)
            {
                cam = new Camera2d(Constants.GAME_WORLD_WIDTH, Constants.GAME_WORLD_HEIGHT);
                cam.Pos = new Vector2(Constants.GAME_WORLD_WIDTH * 0.5f, Constants.GAME_WORLD_HEIGHT * 0.6f);
                h = Constants.GAME_WORLD_HEIGHT;
                w = Constants.GAME_WORLD_WIDTH;
                zoomRatio = 1;
            }
            else
            {
                cam = new Camera2d(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
                // cam.Pos = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * 0.5f, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * 0.6f);
                cam.Pos = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * 1, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * 1f);

                h = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height + 3;
                w = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;

                zoomRatio = 1.12505f;
            }
            startingCamPosition = cam.Pos;

            cam.Zoom = 0.75f;// *zoomRatio;
            cam.Zoom = 0.55f * zoomRatio;
            if (game.camZoomValue != -1)
            {
                cam.Zoom = game.camZoomValue;
                cam.Pos = game.camPosSet;
            }

            rectangle = new Texture2D(gdm.GraphicsDevice, 1, 1);
            rectangle.SetData(new[] { Color.White });
            worldDemension = new Vector2(w, h);
        }