Day 8 & 9

Frankie Rodriguez
4 min readNov 20, 2020

Day 8: I am only beginning to break through the infinite layers that is C#. Despite it being grueling work, I know spending time understanding C# will help me further down this journey.

How to prevent a Debug.Log from printing an X amount of number of times: To do so you must create a variable private bool. However, this variable by default this is false. By adding it to an if() statement, we can set the variable to be true.

  • Two equal signs are used to compare values
  • One equal sign is used to set a value
  • Double &&: translates to ‘and’ in the code
  • Double ||: translates to ‘or’’ in the code

Next I went through the Creating Levels course. Levels can be created indefinitely as long as it is placed in if() statements. However, those statements must check the same condition. See the example below.

Level Creation Code example via Visual Studios & Unity

Creating Quizzes:

  • Creating Grades For Average On 5 Quizzes: First you would need to create a float variable inside the public class that should contain your 5 quizzes. Example: public float quiz1, quiz2, quiz3, quiz4, quiz5;
  • Following that code, you would need to also create the average variable as well within the public class for are grading system: Example: public float average;
  • After doing so your next step would be to generate random ranges of numbers between 1 and 100 for all five quizzes. So to do that we would have implement this into code within the void start().Which should look something like:

Now this still won’t give us an overall average for all 5 quizzes we would need to combine all five quizzes and to do so we would have to have the average equal all five quizzes and then divide that.

Example: average = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5) / 5;

And now we have the code giving us an average range of all five quizzes. We now have to implement a grade for the overall average so to do so we have to create an if() statement where if the average is greater then 90 then we will have the console print out “good job you scored an A” followed with two else if() statements for grades B and C.

If none of the if() or else if() statements are met then we can create else statements i.e. if anything is below 70, it will result in an automatic fail.

That’s how you create a grade system if Unity. I know these seem like random courses and I have veered off from codes pertinent to the game I am creating, but its important to look at the big picture and realize nothing is irrelevant when it comes to learning.

Day 9: I went back to developing the space shooter game. I have decided that I will be alternating my time between developing my game and the C# survival guide. I feel that by doing so, I will have a greater understanding of why things are coded a certain way.

Today I started with placing the triple shot design and coding its movement within the console. I then ended my day by having the player and triple shot interact and collide to enable the power up. I programmed the code so that triple shot is active for only 5 seconds before returning to the single laser shot. Below is a short video of my progress.

Here are the corresponding codes:

Codes for triple shot position, speed, and damage to player via Visual Studios.
Code for Player and triple shot interaction & powerup duration.

Happy coding everyone!

--

--