My journey becoming a Unity game developer: Pseudocode
Objective: Explain why we need to be writing pseudo code by showing examples of where pseudo code can help us figure out the steps needed in an algorithm to solve a problem.
Pseudocode uses informal language that helps programmers solve problems by developing algorithms. Pseudocode helps programmers “think out” the solutions of a program before attempting to write it in a particular programming language. A carefully prepared pseudocode program can easily be converted into a functional program such as C#, C++, Javascript, etc.
Here is a simple algorithm of finding out if a test grade has a score of 65 or more to pass. If not, then they failed and we will print out onscreen they “Passed” or “Failed.” Using comments, we broke down the solution to solving this computer program by checking IF the student’s grade is greater than or equal to 65. We’re using simple and spontaneous language to solve this program, but we’re also using computer keywords to aid our thoughts into creating this algorithm. A variable of grade was created to hold the grade scores when entered, but we had to change the grade from a Console.Readline() string to an integer using Convert.ToInt32 method. The scores were entered using the Console.Writeline() method to show if they have passed or failed.
Now we just enter in the scores and we will get a message to whether they passed or failed.
Even if we needed to be more precise in giving out grades to each student’s score, look at how we can keep our pseudocode simple but effective in breaking down how we need to implement a letter grade according to certain scores.
Using the IF/ELSE commands we still were able to sort through the scores to get the correct letter grade.
Even in game programming, using pseudocode helps immensely in breaking down a problem. We needed our Enemy object to be destroyed when they collide with either a laser or the Player game object themselves. In order for this to happen, using pseudocode we checked IF the OTHER object collided EQUALS the Player’s TAG. Once that condition is met, we’re going to DAMAGE the Player. Also, we’re going to DESTROY ourselves the Enemy in this case. For the Laser object, we checked IF the Other object has a LASER TAG assigned. If so, DESTROY the LASER and Enemy both.
Enemies being destroyed from colliding with lasers and the Player’s ship.
Pseudocode is great to use when programming as it makes us slow down for a moment to really think things through before jumping right in and end up being stuck on some part of code that have us fighting for possibly hours trying to figure out the solution when the answer could have been right in front of our face had we wrote out the solution first.