public BackgroundObjectsHandler(Camera2D camera)
        {
            _camera = camera;
            _halfWidth = Game1.graphics.GraphicsDevice.Viewport.Width / 2;
            _halfHeight = Game1.graphics.GraphicsDevice.Viewport.Height / 2;

            InitObjects();
        }
Example #2
0
        public LevelSelectWindow(WindowHandler windowHandler)
        {
            _windowHandler = windowHandler;
            GraphicsDevice graphicsDevice = _windowHandler.Game.GraphicsDevice;
            _spriteBatch = new SpriteBatch(graphicsDevice);
            _camera = new Camera2D(graphicsDevice);

            _spriteList = new List<Sprite>();

            _background = new Sprite(Game1.contentManager.Load<Texture2D>(@"Images\LevelSelectMan"));
            float windowScaleRatio = graphicsDevice.Viewport.Height / _background.OriginalSize.Y;
            _background.Scale = new Vector2(windowScaleRatio / START_ZOOM);
            _background.CenterOrigin();

            _background.Position = Utils.GetScreenCenter(graphicsDevice);

            _dot = new Sprite(Game1.contentManager.Load<Texture2D>(@"Images\Dot"));
            _dot.CenterOrigin();
            _dot.Color = Color.DarkRed;

            _spriteList.Add(_background);

            Vector2 imageScaledSize = _background.ScaledSize / 2;

            HEART_POSITION = Utils.GetScreenCenter(graphicsDevice);
            KNEE_POSITION = Utils.GetScreenCenter(graphicsDevice);
            NECK_POSITION = Utils.GetScreenCenter(graphicsDevice);
            BRAIN_POSITION = Utils.GetScreenCenter(graphicsDevice);

            HEART_POSITION.X += imageScaledSize.X * -0.005f;
            HEART_POSITION.Y += imageScaledSize.Y * -0.41f;

            KNEE_POSITION.X += imageScaledSize.X * 0.06f;
            KNEE_POSITION.Y += imageScaledSize.Y * 0.43f;

            NECK_POSITION.X += imageScaledSize.X * -0.01f;
            NECK_POSITION.Y += imageScaledSize.Y * -0.65f;

            BRAIN_POSITION.X += imageScaledSize.X * -0.01f;
            BRAIN_POSITION.Y += imageScaledSize.Y * -0.85f;

            BodyPartPositions[BodyPartType.BRAIN] = BRAIN_POSITION;
            BodyPartPositions[BodyPartType.HEART] = HEART_POSITION;
            BodyPartPositions[BodyPartType.NECK] = NECK_POSITION;
            BodyPartPositions[BodyPartType.KNEE] = KNEE_POSITION;
        }