From b5853828bd32315b0918ba2ec8378c9855b5bf52 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Mon, 30 Nov 2020 15:34:59 -0500 Subject: [PATCH] ShmupWorld: pad screen bounds for reaping objects --- Shared/ShmupWorld.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Shared/ShmupWorld.cs b/Shared/ShmupWorld.cs index 8045f94..a2c124b 100644 --- a/Shared/ShmupWorld.cs +++ b/Shared/ShmupWorld.cs @@ -89,15 +89,19 @@ namespace SemiColinGames { } public void Update(float modelTime, History input) { + // Update player & shots. ProfilingList newPlayerShots = Player.Update(modelTime, input, Bounds); - foreach (Shot shot in Shots) { shot.Update(modelTime); } + // Add new shots. Shots.AddRange(newPlayerShots); - // TODO: inflate bounds rectangle - Shots.RemoveAll(shot => !Bounds.Intersects(shot.Bounds)); + + // Reap off-screen objects. + Rectangle paddedBounds = Bounds; + paddedBounds.Inflate(16, 16); + Shots.RemoveAll(shot => !paddedBounds.Intersects(shot.Bounds)); Debug.AddToast("shots: " + Shots.Count); }