Scott Lilly has an excellent, excellent tutorial on his website for how to build an RPG in Visual Studio.
Not just one, actually, but two.
But today we're going to just get halfway through one of the tutorials (the beginner friendly one) and lay out the groundwork done so far to customize it and add some bells and whistles. So, we'll cover some coding, object-oriented programming, and game design.
This blog needs its own dedication/thanks page, but I wouldn't be here without the following dudes:
The Coding Train (Github for Poets)
Scott Lilly (Original Tutorial)
Mark (who kindly created a wonderful all-in-one PDF mockup of the tutorial)
Bob Tabor (for his course on Object-Oriented programming)
But this project is indicative of what learning C# is like in a nutshell: it's learning C# and everything else (design patterns, repositories) in bits and pieces.
The Tutorial (Est. 6-8 Hours)
Lilly's got an OLD and a NEW tutorial on his website, but really the difference between the two is that the OLD is more newb-friendly and the NEW has more bells and whistles. I started with the OLD but decided I wanted to blend the best of both worlds.
Now, there's no point in reiterating everything Scott Lilly has already put together. If you're in the process of learning C# too, I see no reason not to pop off here now and spend a few hours on the tutorial. Have some fun with it. There's even an excellent PDF version of the tut linked on his website.
General Train of Thought:
What I loved about this tutorial was the careful pacing and layering of concepts. I'm not sure how much I was helped by previous exposure to the concept of properties and classes and libraries, but I understood 90% of everything in this tutorial the first time through, instead of barely anything the whole way through. And along the way, it pretty much illustrates the core design concepts of Object-Oriented programming.
Object-Oriented Programming (Est. 4.5 Hours)
Between this tutorial and Bob Tabor's OOP course, I'm really starting to appreciate objects and classes. Sure, there's still debate over which approach in programming is best. But frankly, I don't care. Or, I should say, I care more about have clean, functional code that I can understand. I'll be able to afford opinions later.
Bob Tabor's course is $30 on his website. You definitely don't have to shell out that money in order to learn these concepts. Like I said before, Scott Lilly's tutorial pretty much illustrates the concepts as it goes along. However, Tabor has provided a lot of excellent free material over the years (such as this C# tutorial for absolute beginners), and I wanted to support him. (I'll also say the course had been sitting collecting virtual dust and was happy I found a project that went hand-in-hand).
Ok, but get this. Need a design for your code? Find your nouns. This approach was previously touched upon in Project #1. And here's an illustration of how Scott Lilly did it for this particular project:
But we'll cover more in the next blog.
My Game Design Choices (Est. 2 Hours)
Once the tutorial hit Lesson 11 and we created the World of our game, I took a step back and thought about what kind of world I wanted to create.
Lilly creates a basic RPG landscape, one populated with rats, spiders, rusty swords, and farms. Pretty much, it's a perfect template to run with, throw away , rework, what-have-you. At the risk of adding too much and never finishing the darn thing, I wanted to do some world-building a la Dark Souls and explain the world/make it interesting via the in-game descriptions.
I went with the wintery theme after considering (and not actually participating in) a game jam whose theme was "cold."
So, the first thing I did was take the World Map that Lilly created...
...sprinkled some thought over it, found an open-source mapping tool called Trizbort, dragged and dropped, baked it all, and came up with the following. Below is the first working result. Changes may be implemented as we go along.
And then I thought about the world, going back to that theme we mentioned earlier: cold. Eternal winters and Nordic landscapes are popular in fantasy for a reason. How to invoke that chilly nostalgia in players while also spicing things up a bit? All that thought went into the types of items and monsters, the names of locations, and the lore-rich descriptions.
(Items did not previously have a property for Item Description, so I added that to the Item base class. Hey look Mom, no hands).
This also opened up different avenues of gameplay. While more is explained in-depth in the Bells and Whistles section, I decided I wanted to add the following to the game design:
Alright, based on all of that, we can define the new additional classes and objects of this extended game:
Words of Power
Martial School (to store information on Attack/Defense/Evade maneuvers)
Mystick School (to store information on Light/Dark/Water/Fire maneuvers)
Ritual (dealing with the Victory, Defeat, and Player Progression after battles) (at least, I think we'll need a class for this)
DeBuffItem (added two poisons to the game that gave adverse side effects)
Alcohol (a special item that both buffs and debuffs)
I'll also need to modify the code for specific interactions with the Rusty Sword, which was now the only weapon in the game, but which could progress along similar lines with the player's progression. The player will be able to name the sword and use it to unlock certain areas.
To keep track of the list of items in the game and their descriptions, I went Full Geek and started making a spreadsheet on Google Sheets. Here's what we've got so far:
Bells and Whistles (Est. 6-8 Hours)
At this point I went over the NEW tutorial to see what was different. Would I have to start over from scratch?
(I should be honest and say that I looked at the NEW tutorial before I was even halfway through the OLD one, wondering what I needed to plan for).
What I liked best about the NEW tutorial was that it included Character Creation and more visual UI.
But I began thinking of my own design choices and how I could already look at implementing this early in the new conception stage.
One thing I wanted to do here (and in future projects) was more to put in more thought when it came to "clearing" battles. Specifically, the aftermath. Whether you're fighting a sewer rat or the final boss, most RPGs conclude battles in the same way: little victory diddy, XP points, gold, loot. You're essentially rewarded with a bell, a whistle, and a glorified Excel spreadsheet outcome.
Well, I liked the idea of battles also having an emotional impact on the Avatar (and player, with any luck). But nothing that would go so far and speak down to the player or make them feel guilty for "killing" things in game. Really, it was more about treating the world, the creatures, and the player Avatar more seriously--and so the player could feel like they were being taken seriously.
So, fighting the battle is half the battle. Or, I should say, half the reward. If a player successfully kills all enemies in combat, they must perform a ritual. This is just a cultural touchstone in the game world, but gameplay-wise, the player makes a small offering of thanks to the memory of the deceased. I remember reading somewhere about several different native American tribes doing something similar after a hunt. It's a Judeo-Christian tradition, too: historically, prayers of thanks were said after a meal.
So, no, it's not a plug for vegetarianism or anti-violence. But to my mind it does several things:
Rinse, Repeat, Release
Of course, now the next step is to continue taking steps.
I'm trying out my ideas as I'm following the tutorial, modifying as I go along.
And playtesting and debugging, ad nauseum as they do, till I get a working prototype.
Until then, uh, pray for me!
And hey, thanks for stopping by!
In Excelsis Deo.
Another day, another generator.
This generator provides a list of personality traits--but embellishes them with adverbs. To describe someone as accidentally protective or waspishly honorable piques my interest.
This one was still pretty simple and piggy-backed on the last generator I made, but I still had trouble figuring out how to cleanly loop or exit the application. I ended up copying the same method I used in the last project, but the whole structure has still been implemented in a slightly different way.
This is a generator I simply wanted for myself. Still trying to figure out how to make these applications playable--may eventually need to convert them, but for now, here's some examples of what you can get with this generator:
Till next time.
In Excelsis Deo.
What I Learned:
Till next time.
In Excelsis Deo.
Codewise, this project is way simpler than our Consignment Shoppe Demo. Probably because the Demo was coded by a professional and this one was coded by me.
Today we've got a simple Mad Libs console application in C#. It uses random, switch case, an array, Console.ReadLine, Console.WriteLine, and a loop.
I enjoyed doing this from scratch and having a finished product in less than an hour!
Here's the Code:
Arrays and Switch Cases:
The main hurdles were making sure the array, switch case, and random variable worked together. I may have cheated a little, but in order for each of the switch cases to match up with the appropriate author in the array, I put in a dummy string "" for the first array index. Without this dummy string, the random.Next feature would pick, say, Virginia Woolf, who is Case 5, but because Arrays index starting from 0 instead of starting from 1, Virginia Woolf was actually considered Case 4, so the text was off by one.
There's probably a better way to do that, but it worked, and this is all learning curve right now.
Instead of just one determined writing sample that plays out the same each time, I wanted to create a relatively tidy index of random writing samples from famous authors: Willy Shakespeare, Jane Austen, Homer, Virginia Woolf, Herman Melville.
So I created a random variable, gave it an index, and plugged it into a switch case--all things that would still have sounded like mumbo-jumbo about a month ago.
Clean Up On Lines 17, 18, 19...
Reminded of the importance of spaces when dealing with multiple lines of strings. The things you take for granted!
It's still not perfect, but at least it reads a little more clearly!
Replay Or Exit:
Had a bit of a time with this one, and it's still not the clean exit I want. But I learned the importance of method parameters. I originally had everything in the Main method, then realized I couldn't easily ask the user if they wanted to play or exit. So I put the main game loop inside a method called Start and then allowed the player to either choose to play again or exit. The exit still goes to debug mode instead of closing down the console, but for some reason neither this.Close, Application.Exit, or Console.Close/Exit/Whatever seemed to be recognized.
But the point, this baby is finished, and I know what areas I need to work on.
The writing samples used in the application are from the following:
1. Shakespeare's "Much Ado About Nothing"
2. Jane Austen's "Emma"
3. Herman Melville's "Moby Dick"
4. Virginia Woolf's "Orlando"
5. Vince Lombardo's translation of Homer's "The Odyssey"
Glad you were here; till next time!
In Excelsis Deo.
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.
Making A Screen Saver in Visual Studio #C
Last week, I "completed" this screensaver tutorial. Can't say I completely understand everything that was going on (plus I couldn't get preview mode to work), BUT, it still demystified the following things for me:
Gotta admit, it was a thrill going back over some of the code he had written and suddenly going "A-ha!"
I still couldn't have come up with the code itself, but my ability to read and comprehend is getting better, bit by bit.
Riddle Me This
We talked about programming sub-skills a few blogs back, and we came to a conclusion: puzzles. Mental gymnastics, learning how to learn, puzzles, riddles--yes, good. Good for budding programmers.
So I started doing Sudoku puzzles. But going beyond what I used to do, actually looking into two things:
1) Mental techniques for improving my form/efficiency (I turn off the clock on my Sudoku app, but I started caring about the time it took me to complete a puzzle, insomuch as I wanted to improve each game and not just coast through each game for entertainment purposes only)
2) Focus (being able to focus on just this puzzle from start to finish, no interruptions)
And there's a third thing hidden in there:
3) Problem solving
Mental techniques, focus, and problem solving: all of them sub-skills for programming.
I couldn't believe it took me an hour to finish my first Sudoku puzzle. It was only on moderate difficulty.
But the second time, it only took me twenty minutes.
And then I couldn't believe the improvement. I even noticed that I was feeling much less foggy within a week of starting the exercise.
The idea of completing Sudoku puzzles actually came from V. Anton Spraul's book, Think Like A Programmer. In it, he also mentions a gem by the name of Sam Loyd.
I mean, just check out this guy's dedicated web site.
Sam Loyd was an early 20th century puzzle pioneer, and his puzzles are just beautiful to look at. I went ahead and ordered a few of his collected riddles and puzzles, figuring they'd make great keepsakes and handy tools for sharpening my rusty problem-solving skills.
So, I guess the lesson from this practicum is: strengthen your mind, not just through programming. Especially when actually being able to understand programming, let alone being able to program yourself, can be slow goings.
Bonus: Things I Tried To Make Learning More Automatic and Organized
1. Defining My Environment
The same computer I use to write short stories, browse the internet, check emails, and play video games is the same computer I use to work on my projects, take tutorials, write my blog, and watch lessons.
Oh, and it's also in the room where I read and sleep.
Needless to say, some days the temptation to noise and distraction is overwhelming.
So I tried two things.
I made sure all my clothes remained in my closet, at least 80% of the time.
I lit a candle every time I had trouble focusing on just coding.
Keeping my room an average level of clean kept me from anxiously nitpicking it or anxiously ignoring its faults. And lighting that candle served as a signal to my brain that it was time for one specific thing.
2. Getting Up At The Same Time Every Day
I really struggled with brain fog between Blog #5 and Blog #6. So I did what I knew I should have been doing all along: regulated my sleep schedule.
This is easier said than done. I should say I wake up at relatively the same time every day. And that this one is a work in progress.
But I decided that this task was important, even if it felt only tangentially connected to my more passionate goal, which was to wrap my head around the concepts we've been exploring. I realized, however, that I was chasing stimulation instead of results.
And it's hard to admit, sometimes, that results are a product of time and, not, strictly, productivity, or what passes for productivity.
So, I've made consistency a priority, even if its slow goings.
3. 30g of Protein within the first 30 Minutes of the Day
Sometimes I really don't want to do this one (and, um, sometimes I just don't do it), but I know its results first-hand. I started this habit way back in high school and the results spoke for themselves: I lost weight, gained energy, and had a habit I could rely on.
So I retuned this habit recently, taking Timothy Ferriss' advice to eat 30g of protein within the first 30 minutes of waking up. This is one of Ferriss' MEDs (minimum efficient dosages), or the least you can do for the most results. In this case, eating 30g of protein within the first 30 minutes of waking up is a two-fold no-brainer:
A. It regulates fat like nothing else. Without changing anything else in their diet or exercise routine, obese practitioners who put this habit into daily usage saw a monthly increase in weight loss (Ferriss' own dad went from losing 5 pounds a month to 18+ pounds a month from this ONE thing alone--he didn't regulate any other part of his diet and he didn't start hitting the gym).
B. It regulates mood. Some days I'd be fine skipping breakfast--could even feel heroic. But the compound interest would result in a few inefficient, foggy days about a week later--it almost always works like that, doesn't it? The results of our decisions can feel so delayed it's hard to say what caused the sudden lag.
4. Putting A Win At The Beginning of the Week
Ray Bradbury once told struggling writers to aim at writing 52 short stories a year, one for every week. I mean, you can't write 52 bad short stories in a row.
Realizing that the first week of January had yet to pass, I thought--why not? Some would be prompts, some would be flash fiction, some would be just for me, some would definitely be aimed at contests and publishing.
Then I made one more caveat: I'd make sure I got the story done at the beginning of the week. Monday or Tuesday, using Joyce Carol Oates' advice of just writing the rough draft in one complete gulp. "You can edit for weeks afterword." Well, hopefully not, but as weird as it sounds:
We're going for quantity over quality this time around.
And I'm putting this goal at the beginning of the week so I have psychological goodness running through the rest of my week. When I'm struggling with making progress or staying focused or skipping breakfast or some other misstep, I can think--"Yeah, but I finished that thing."
And I finished that thing today, y'all.
It feels good.
Bonus Bonus: A Good Read
Great interview from game designer Chris Avellone.
In Excelsis Deo.
Table of Contents
A. The Beginner's Creed
B. The Fluff Behind C#, Visual Studio, and .NET
C. First Application: Basic UI in C# and Visual Studio
A). Learning to Learn
There's a hidden gem in one of the forewords to Gloria P. Flores' Learning to Learn and the Navigation of Moods: a Beginner's Creed written by computer operating systems insturctor Peter J. Denning.
While I was going to give a summary of the book itself, seeing as I haven't finished it, I thought I'd just share this. Bonus points for reading it every day for a week.
Peter J. Denning's The Beginner's Creed
I am a beginner.
I am entering a new game about which I know nothing.
I do not yet know how to move in this game.
I see many other people playing in this game now.
This game has gone on for many years prior to my arrival.
I am a new recruit arriving here for the first time.
I see value to me in learning to navigate in this domain.
There is much for me to learn:
The basic terminology
The basic rules
The basic moves of action
The basic strategies
While I am learning these things I may feel various negative reactions:
Overwhelmed at how much there is to learn
Insecure that I do not know what to do
Inadequate that I lack the capacity to do this
Frustrated and discouraged that my progress is so slow
Angry that I have been given insufficient guidance
Anxious that I will never perform up to expectations on which my career depends
Embarrassed that everyone can see my mistakes
But these moods are part of being a beginner. It does not serve my goal and ambition to dwell in them. Instead,
If I make a mistake, I will ask what lessons does this teach.
If I make a discovery, I will celebrate my aha! moment.
If I feel alone, I will remember that I have many friends ready to help.
If I am stuck, I will ask for help from my teachers.
Over time, I will make fewer mistakes.
I will gain confidence in my abilities.
I will need less guidance for my teachers and friends.
I will gain familiarity with the game.
I will be able to to have intelligent conversations with others in the game.
I will not cause breakdowns for promises that I lack the competence to keep.
I have an ambition to become competent, perhaps even proficient or expert in this game. But for now,
I am a beginner.
B). What is Visual Studio? C#? The .NET Framework?
You should know--the majority of this article is background information. Foundational is the better word. It might seem like a lot of set-up for a little outcome, but we're talking here about concepts that we will need to take as given when we go to work on future projects.
It doesn't hurt to spend a good portion of our time familiarizing ourselves with these terms.
So my practicum assignment was to make a basic UI (User Interface) form in Visual Studio.
Here's some examples of UI:
Visual Studio is an IDE (integrated developer environment), which is to programmers what Microsoft Word is to writers. It organizes, corrects, and sometimes even auto-completes snippets of code, provides information on what does what, comes with ready-made templates, and takes care of your files.
IDEs usually come with frameworks. Our IDE, Visual Studio, uses what's called the .NET Framework.
First of all, what IS a software framework?
Stack Overflow's Neha Choudhary gives a great concrete analogy:
"If I told you to cut a piece of paper with dimensions 5m by 5m, then surely you would do that. But suppose I ask you to cut 1000 pieces of paper of the same dimensions. In this case, you won't do the measuring 1000 times; obviously, you would make a frame of 5m by 5m, and then with the help of it you would be able to cut 1000 pieces of paper in less time. So, what you did was make a framework which would do a specific type of task. Instead of performing the same type of task again and again for the same type of applications, you create a framework having all those facilities together in one nice packet, hence providing the abstraction for your application and more importantly many applications."
And here's your more standard dictionary definition from Techopedia:
"Frameworks take the form of libraries, where a well-defined application program interface (API) is reusable anywhere within the software under development. The purpose of software framework is to simplify the development environment, allowing developers to dedicate their efforts to the project requirements, rather than dealing with the framework’s mundane, repetitive functions and libraries."
So, a framework makes it so we don't have to keep reinventing the wheel.
There were two more terms nested in there that are important to go over: library and API.
In programming, a library is a collection that stores frequently-used routines so we can easily access them. Hey, that sounds a lot like a framework. Well, a framework is a type of library. (I'm finding a lot of cross-pollination in programming terms--and YES, it IS annoying that most of the definitions have about five unknown definitions within their definition).
An analogy. Let's say we want to program a sandwich, and we have access to a library of sandwich recipes. Well, when we're programming our sandwich, it's not enough to list the ingredients. We also need to give clear instructions, or routines, on where to gather the ingredients and how to put them together.
Now, it would be really tedious if every time we wanted to make a sandwich we had to laboriously explain how to find the bread box, open the bread box, locate the right bread, untie the bread bag, take out only two slices of bread, re-tie the bread bag, put the bread bag back into the bread box, close the bread box, then....
We have a library for that. We just pull up the, say, GatherIngredients() function, and our little program fills in all those steps. We get to focus instead on specifying specifics about the sandwich--pickles or no pickles, light on the mayo, if turkey is available use that if not use salami, while frying bread cut the avocado slices, trim the crusts only if Johnny is asking for a sandwich, etc.
Key Basic .NET/Visual Studio Takeaways
Key Terms: IDE, software framework, library, API, .NET, Visual Studio, C#
C). Notes on Making Basic UI in C# and Visual Studio
Setting Up and Explaining the Fluff
1. Created Windows Form, popped up with Form1.cs and Form1.cs[Design]. You can drag and drop various buttons, text boxes, and input types. However, we still need to alter the code to tell the program what to do with those inputs when they receive feedback from the user (feedback includes clicking or unclicking a checked box, typing in text, etc.).
2. Anything you drag and drop onto the form is added to the Form1.cs file. Visual Studio generates pre-made code and puts them all under a public partial class. What does this mean?
3. Let's look at the code.
Within the curly braces, we’re telling the program what we expect this public Form to do. Well, we want to InitializeComponent(). Those open parentheses are how we tell the program—execute! Think of them as the imperative case in C# programming—a type of punctuation, if you will. The semi-colon ; is the equivalent of a period. Without it, computers can’t even tell it’s a run-on sentence—it just stops short and does a D’oh!
‘InitalizeComponent()’ is a built-in argument. If you scan to the top of the program, you’ll see a long list of lines staring with ‘using.’
These are all the namespaces that this program is using. Within these namespaces, our program can pull from the ready-made functions, arguments, coding pieces already included—no need to define what they do, they are built into the line of code itself. Sweet, right?
Confused by all the periods? While it’s not important to know what ALL of these mean now, we can break down just one example:
Using is a keyword. System is the namespace. Collections is a class within that namespace.
Continue with the library analogy and think of this like a book.
‘System’ is the name of our library. There’s a shelf called ‘Collections’ within that library, and on that shelf, there’s a book called ‘Generic.’ Like the Dewey Decimal System at your local library, the computer knows how to navigate to the specific info you request.
(We could even go further and say in that book there's a specific chapter, and in that specific chapter there's a specific sentence, etc).
So, InitializeComponent() is built into the libraries we are accessing, and allows us to, you guessed it, initialize (prepare) the component (in this case, the Form).
4. Now for all these ‘private void’ things. Notice that there is a private void class for each of the buttons/boxes I dragged onto our Form Design. Visual Studio has set up a basic object for us, but it’s up to us to define that object’s behavior. That behavior will be defined in the curly braces. But what about all that STUFF that comes before the curly braces?
*Public vs. Private. So far we’ve seen public classes, and now we see private classes. When something is public in C#, that means the program at large can access the data within that class. But if a class is private, only that class has access to what is within it. So, all our objects, our buttons, are private void.
*What is void? Void is nothing. Eh? What? I know; what’s the point of declaring nothing? In this case, we’re just declaring that we aren’t returning a value. We don’t need the program to pull up an error just because we haven’t said—”Hey, this is equal to 3, or true, or bananas.” If we executed this code without any behavior written between the curly braces, we’d simply have the Form Design we created. While we couldn’t do anything useful with this form, we at least wouldn’t be thrown back an error.
*Name. ‘Private Void’ is followed by the name (bloodTypeCombo, etc.) we’ve chosen to call our class or object. Simple as that.
*Parentheses and Arguments and Parameters. We mentioned before that the () parentheses imply ‘Execute!’ That’s not the most technically accurate answer, but it’ll do for now. We can actually ‘pass arguments’ and ‘pass parameters’ into these parentheses. It’s what the behavior we code into the curly braces will be referring to.
Parameters are used to pass values or variable references to methods. The parameters of a method get their actual values from the arguments that are specified when the method is invoked.
So, "parameters" refer to names, and "arguments" refer to values bound to those names. (Thanks to Stack Overflow’s Pavel Minaev for this definition).
In this case, we have two parameters: sender and e.
Where The Actual Coding Begins...
5. Here’s where I learned to define the behavior—I.E. where the actual coding began.
But I'm only going to explain one part in-depth.
Now, let's break this down:
Overall Summary: This class defines the drop-down combo box that allows the user to pick their blood type, from A, B, AB, or O. It creates a string called 'bloodType' that gets its value from the user's input.
Breaking It Down:
Key Visual Studio Window Form Takeaways
Studying programming is like getting on a never ending staircase--each step has steps popping out of those steps popping out of those steps popping out of those steps....
What I'm trying to say is that it's easy to feel like you need to understand a million things in order to understand one thing. And don't get me wrong, going for depth is the surest way to understanding something intuitively and being able to use it correctly and quickly.
However, for all that we covered today, there are really just four basic moves we made in creating a C# application:
1. Setting up a project in Visual Studio.
2. Navigating the Properties tab.
3. Understanding the boundaries and distinctions of a C# class.
4. Finding and Choosing Events Handlers (also known as the behavior or method of the code).
Key Terms: class, event handler, method, namespace, keyword, public, private, void
Alright, first practicum down!
And no, you couldn't put together a Windows Form application based on my scattered notes.
There's a lot more going on underneath the hood, but here's "proof" I finished my first project. In future essays, I'll go for clarity and actually being able to explain this stuff.
C# is still quite misty to me, but this method of studying (pouring more into meta-learning, writing notes over several days, working on a custom project with slight tutorial help and Googling) is much more intensive than what I was doing before (isolated tutorials) and, therefore, feels less illusive.
We'll keep peeling back the layers bit by bit, and eventually I can put together a one-pager that'll reach elegant brevity. That's the dream.
Until next time.
In Excelsis Deo. (And Merry Christmas!)
K.W. writes novels, short stories, the occasional ode, game scripts, and (with actual evidence!), this here blog.