I may be creating some programming lessons. Yep, there are plenty of those, but I want to try and give it my own spin. Plus, recently, I got some pretty good opportunities. I will be posting my drafts here.
0
I will be using Unity 3D. Learning to program is like learning to speak, it's 90% of the work. Learning a specific programming language is more like learning a dialect - the remaining 10%. Mastering the language may be a different topic though. So it doesn't matter where you start learning, your progress will be moving in the same direction.
There are perfect tutorials on how to actually create a game in a day and play it on your phone on Unity website. I wouldn't dream of making something even more accessible. This tutorial is aimed to give you a general understanding, to make you more comfortable with programming. This works for those developing in Unity or any other language. It starts from basic concepts, explores general misconceptions and later dives deeply into coding standards. It is expected that you'll be practicing in parallel.
Here we go
Many see unity as a fast tool to put together a game, but in reality it has a much more "blank slate" nature then some may think. Any application that needs 3D graphics can be and many are made with Unity. Unity doesn't revolve around the concept of player or gaming. In Unity you put geometrical shapes in a Scene, write C# code to make them do what you want. That is all there is to it, and that is all there is to programming.
To understand code it's important to understand how processor works: it can do one thing at the time. It can do math operation, it can move data from one place to another, like when you copy or move a file, and when it executes code, it can jump, for example, from line 300 to line 600, and it can compare stuff. In the beginning programming languages were more similar to a machine code. And a machine code is a long list of instruction. No matter which language you use, before your code can be executed, it needs to turn into machine code. When you write a code, you name things: instead of using X, Y, Z, like in school, you can write: SALARY, DAYS_WORKED, OFF_DAYS to make it easy for you. The computer will blindly do what you told it to do, it doesn't need to know what those numbers are, so he doesn't need any of that naming stuff, he will replace those names with addresses to know where in memory that data is. And that address is also just a number.
Generally, the code itself will not change after you started the program, it is the data that will change. For example, the grades of your students is the data. Code (or instructions), are what you will do with that data, like Add, Calculate average and so on. When you work with your typical calculator, you actually write data (numbers), and instructions (operators +, -, /, *). And if you have one of those fancy calculators, you can write complex formulas with X, Y, Z and whatever, and then just enter those X,Y,Z values to have them processed based on the formula. What most people find challenging when starting to learn programming, is how the math we learned in school is relevant to updating your twitter...?
To answer that question, first of all we have IF THEN - it basically means that depending on some conditions program will do or not do certain operation. So it's no longer just a list of instructions. Back in a day, the old time I talked before, you would put GOTO markers in your code. You would write START: then do some operations, and if we need to do those same operations, we would write GOTO START; As you might imagine, it's really easy to end up with a huge page of code with tons of markers. But now, no markers, you will not see any in modern day code. We realized that there is a limited number of scenarios where you need to return and do something again, so why not make a special way to write them without creating new marker, and so the code (not an actual code) ...
START_OF_THE_FRAME:
If W is pressed then player position Y = player position Y + 1
if enemy Y < player position Y then player health = player health - 1
If player Health > 0 then GO_TO START_OF_THE_FRAME else GO_TO_DEATH_SCREEN
... turns into:
while (player.health>0) {
If (Input.GetKey(KeyCode.W)) player.position.y += 1;
if (enemy.position.y < player.position.y) player.health -= 1;
}
ShowDeathScreen();
You may compare two pieces of code (again, first one is sort of a fake code), they do the exact same thing. Take your time, this right here is what programming basically is. In your first program first you will check if user pressed a certain button. Then you will write a code that will be changing some data if he did (like player position in current example). And in the end, based on all that, you will paint everything else on the screen: sky, hills, trees, enemies, flowers. But in slightly different position then you did last frame, because player moved.
This is it for the introduction. Have to mention something:
player.position.y = player.position.y + 1;
player.position.y += 1;
player.position.y ++;
All three of those are the same thing. It just we use (A = A + X ) so much that special syntax (A += X) was created. And we often need to just add 1 to a number so A += 1 and A -= 1 turns into A++ and A--. There is not much depth behind it, just convenience.
Because computer has such a limited number of basic operations it can do, you will soon realize programming to be more about learning to organize your code, rather then memorizing how to do something. At first it will feel like there are tons of things to learn, but reality is the opposite - under things that look unfamiliar most often you will find basic concepts you already know.