Hey, glad you're here.
We're almost through with the 5 practicum assignments I attached to the first module in the Game Dev Ultralearning project!
I came across this tutorial to make a simple platformer in Visual Studio. This was the perfect extension project from Projects #1 and #2. Each tutorial, chosen at random, has somehow gone back and filled-in-the-blanks and trouble spots from previous tutorials.
Now, like the screensaver tutorial, I'm still basically rewriting code verbatim. The difference here is that many of the concepts covered in this tutorial felt more like review. Before my formal Ultralearning project, my self-study was sporadic at best. However, I'm glad that I covered the following, even if I wasn't sure how they'd all come together in the end:
A. MonoGame Course
C. C# Fundamentals for Absolute Beginners
It's gotten to that early stage in learning this subject where I'm able to "read" code almost like it were a book. A book written in a foreign language, but a foreign language I'm finally just the teeniest bit comfortable with.
In addition, re-writing all the code from scratch significantly improves literacy and understanding of the code at hand. This tutorial's style of explanation, presenting chunks of code at a time instead of line-by-line AND providing comments side-by-side, was way more effective than previous tutorials that broke everything up to a halting pace.
Here is the code in its entirety:
Pretty much the only thing I added was displaying the score in the MessageBox after the player was done.
I was going to do something more from-scratch, but I only found solutions that either wrote to the console line or to the MessageBox itself, instead of on the UI of the platformer. I KNOW there's a way; in fact, there's an oceanful of tutorials on simple score counters. But between this and other projects I grew stale on this practicum and wanted to spend my creativity on the next assignment. I kept my notes, seen below, but the important bit is when we move on into studying C# a bit more in-depth.
So three down, two to go, with the intention of practicing more from-scratch coding.
The important first step: thinking this through and writing it down on paper before looking up how someone else would do it or simply banging away at the keyboard.
Looking back over the game code, we have the following already set up for us:
Right now, we have no way of displaying this score to the player.
In the screenshot at the top of this blog, I have a label named 'Score' and an empty text box. I haven't hard-coded anything with them yet, so they are just visual displays on the form and nothing more.
My first thought is--how do I code a line that displays the score on the screen and dynamically increases every time the score increases within our block of code above?
At first, I thought I should focus on the display first then the increase. Then I realized, this should be on in the same. As long as I could get it to display "score," then whatever "score" was at the time, that is what would be displayed.
So, how to call the int 'score'? Would a textbox work? It sounds simple, even to me, but for this fact: I don't have any methods or events memorized, and am still fuzzy on the scope of variables.
Now, this exercise brought me into Overstudying Mode. Which is a good thing, especially here at the beginning. I've been meaning to create an [Anki] deck to help me memorize C#'s keywords, methods, and events. This won't substitute actually coding with these concepts, but I figured having a better handle on what the language could do would be helpful and at least save me from googling every little thing.
So, I decided to make an Anki deck before just looking up how to code a simple score display.
Now, I want you to appreciate something:
These right here are ALL of C#'s keywords.
I counted (and confirmed elsewhere to be safe): there's only 104 C# keywords in the language.
Remember how in Blog #8 I quoted Andy Harris as saying programming languages are easier than human languages? I KNOW you had to memorize more than 104 words in your high school Spanish class.
What's even better is that out of these 104 keywords, there are only 10-20 that any one programmer uses frequently.
So let's start with those.
Looking at the code for the platformer game, Visual Studio already highlights any keywords in blue.
C# Literacy Detour
Here are the 8 most frequently used C# keywords:
In Excelsis Deo.
K.W. writes novels, short stories, the occasional ode, game scripts, and (with actual evidence!), this here blog.