/// <summary> /// Updates the Level /// </summary> /// <param name="elapsedTime">the time elapsed between this and the previous frame</param> public void Update(float elapsedTime) { if (Paused) { // Unpase on space press if (Keyboard.GetState().IsKeyDown(Keys.Space)) { Paused = false; } } else { // Update the scrolling distance - the distance // the screen has scrolled past the Player if (Scrolling) { float scrollDelta = elapsedTime * (CurrentMap.Layers[CurrentMap.PlayerLayer].ScrollingSpeed); scrollDistance += scrollDelta; ScrollingShooterGame.Game.Player.Position -= new Vector2(0, scrollDelta / 2); // Scroll all the tile layers for (int i = 0; i < CurrentMap.LayerCount; i++) { CurrentMap.Layers[i].ScrollOffset += elapsedTime * CurrentMap.Layers[i].ScrollingSpeed; } } // Update only the game objects that appear near our scrolling region Rectangle bounds = new Rectangle(0, (int)(-scrollDistance / 2) + 300, CurrentMap.Width * CurrentMap.TileWidth, 16 * CurrentMap.TileHeight); foreach (uint goID in ScrollingShooterGame.GameObjectManager.QueryRegion(bounds)) { GameObject go = ScrollingShooterGame.GameObjectManager.GetObject(goID); go.Update(elapsedTime); ScrollingShooterGame.GameObjectManager.UpdateGameObject(goID); } } }