Day 7: The Importance of Writing Pseudocode

Programming involves solving a lot of abstract problems. It’s always a good idea to tackle this problems by writing a plan first. Without a plan, we might as well just be randomly hitting our keyboards and hoping for the best.

This is what comments and “pseudocode” is for. Pseudocode is basically just typing out what we want to do in English (or your native language). This gives us a written idea of what our actual code should be doing, so that we don’t get lost.

Let’s continue from where we were last time and look at an example.

Here, we want to restrict the bounds of the player’s movement so they can’t go too far up or down. I’ve written a plan of how to do this with comments, and then we can go actually write it with C# code.

What’s nice is that any time our pseudocode has the word “if”, that’s a cue to write an if statement in the actual code.

It’s even more important to do for more complicated behaviors. Here my comments show what we want to do in very basic terms, and also suggest some math that will solve the problem.

We can use Mathf.Abs to turn any number positive, and Mathf.Sign to get the positive or negative sign of a number. We can know to use these functions because that is what is required by the pseudocode.

Here is the end result. The square can only go so far up or down, and it will wrap around the screen if it goes right or left. The power of pseudocode made this very easy to implement without getting stuck for hours.




I’m a passionate and talented software engineer seeking an opportunity in game development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CakePHP vs Node.js- Which one to choose for web application development?

“If it turns out that this is incurable, would you marry me?”

How I Stopped Being a Hater and Learned to Love Rails

Experimental: Syntax AI with React.js

IOS and Android App Development Trends To Watch Out in 2022

Python Memory Management

What I love about DevOps is that in the end, it’s all about people. — Polar Squad

Checking out Libraries in C

View of the stairwells in the Stuttgart City Library in Stuttgart, Germany.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Blake Zoeckler

Blake Zoeckler

I’m a passionate and talented software engineer seeking an opportunity in game development.

More from Medium

Day 6: Doing Cool Laser Tricks

How Not To Make A Game

Side Questin — Day 1

A turtle crawling on sand

Starting to feel like a real game!