Exemple #1
0
        public void Update(GameTime gameTime)
        {
            //move camera
            Vector2 destination = CameraFocus.Pos + new Vector2(blockWidth / 2, blockWidth / 2) - new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height * 3 / 5);

            if (destination.X < 0)
            {
                destination.X = 0;
            }
            if (destination.Y > -graphicsDevice.Viewport.Height)
            {
                destination.Y = -graphicsDevice.Viewport.Height;
            }
            camera += (destination - camera) / 5;

            //load/unload
            LoadManager.Update(new Rectangle((int)camera.X, (int)camera.Y, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), loaded);
        }
Exemple #2
0
        public void Initialize(float blockWidth, GraphicsDevice graphicsDevice, Action OnCompletion)
        {
            this.blockWidth     = blockWidth;
            this.graphicsDevice = graphicsDevice;
            this.OnCompletion   = OnCompletion;

            physicsMangager = new PhysicsManager();
            loadManager     = new LoadManager(this, blockWidth);

            inputObjects = new List <IInput>();
            foreach (List <List <GameObject> > column in LevelObjects)
            {
                foreach (List <GameObject> tile in column)
                {
                    foreach (GameObject gameObject in tile)
                    {
                        gameObject.Initialize(this, blockWidth);
                        if (gameObject is IInput)
                        {
                            inputObjects.Add((IInput)gameObject);
                        }
                        if (gameObject is ICameraFocus)
                        {
                            cameraFocus = gameObject;
                        }
                    }
                }
            }

            if (CameraFocus != null)
            {
                camera = CameraFocus.Pos + new Vector2(blockWidth / 2, blockWidth / 2) - new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height * 3 / 5);
            }
            if (camera.X < 0)
            {
                camera.X = 0;
            }

            loaded = LoadManager.LoadFirstScreen(new Rectangle((int)camera.X, (int)camera.Y, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height));
        }