Nov 15, 2017

Comfort programming Introduction


Edited: Nov 15, 2017

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.



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) ...



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 (>0) {

If (Input.GetKey(KeyCode.W)) player.position.y += 1;

if (enemy.position.y < player.position.y) -= 1;




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.


New Posts
  • A code for very basic educational game
  • Links to track stuff:
  • I'm from Ukraine, and it's a good country. Some people there are great in every way, like my friend Taras. But most feel unsafe due to constant discourse in power - a government that doesn't know how to handle Russia, by making the worst decision possible every bloody time. So, about me, where to start ... well, Taras, I mentioned him before, thinks it's impressive that I had many different jobs, including a year of Senior Waiter position in Burj Khalifa (Tallest building in the world, Dubai), a couple of month in the drilling company, an english tutor for kids, and at least five more jobs. I tried to avoid full time programming jobs as much as possible, because I would want to delete Unity from my home computer, just like Taras did. He develops applications with Unity, but not games, a cool AR projects. He is like super talented, he had his own Death Metal Band, and he was doing all the work: producing, postproduction, organising everyone. Now he is married, doesn't seem to be doing much of that. His wife is a musician too. How great is it to find someone with similar passion. I think he still plays, and he has a kid, probably will tech him to play too. The boy will be the next Mick Gordon. Taras was actually the one who helped me start programming, and also a few years back, when I said that I want to quickly write a game for mobile, what is the best language, he told me to learn Unity. And here I am now, same as before, but with my own website. This is basically my whole story. There was other life stuff, but this pretty much all you need to know about me.
GitHub icon
Discord icon
Facebook icon
Instagram icon