2D Shooter: Keeping the Code Organized

Sabrina Windsor
2 min readMay 21, 2021

--

As we get further along in developing a game, the code is going to get longer and longer. What happens if we need to make changes to a certain part of the code and we can’t find it because we don’t have a way to organize it? We’ll you will like have to do a lot of scrolling and searching by eye to find exactly what you’re looking for.

Or we can create new methods.

This will let us keep our Update method nice and tidy, and every mechanic will have its own box to be in basically. Player movement will be in a box, and lasers will be in a box, health interactions will be in a box.

All we would have to do is call up the new method in the Update method, so we can continue to see our code in action.

We’ll go from our code looking like this:

To this:

There, now its looks so much better!

--

--

Sabrina Windsor
Sabrina Windsor

Written by Sabrina Windsor

Currently learning to code with the help of GamedevHQ in order to someday my my game ideas come to life!

No responses yet