One of my favourite lil #gamedev tricks is that if you iterate over your array backwards you can remove elements by swapping with the last element to avoid the need for a second loop or shifting of the array contents!
Comments
Log in with your Bluesky account to leave a comment
One of my favorite tricks! You can do it forwards too by just not incrementing the index when swapping and instead decreasing the upper boundary. Tbh I'd forgotten backwards was "simpler" though, I need to check a couple places in my code now ;)
Comments