Making Games with No Previous Experience - Part 1: Code
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.
Fear not! I was in the same position a year ago, but all you need to break is the psychological barrier that you’re missing years of experience necessary to do anything.
The only prerequisite is the ability to think logically.
Part 1: I don’t know how to code!
This is fine. Throughout my teenage years, I would occasionally decide I’d learn to code, follow some guide, and get struck by a wall of text just to get a console to display “Hello World”. It wasn’t until on my degree (Physics), when I had a compulsory module of C and was forced to sit in a room and code that I could actually be sufficiently motivated to learn.
The course was perfect though, because all the “walls of text” were covered in non-compulsory lectures. The actual exercises were extremely brief, assuming you’d attended the lectures and essentially only saying “This is a double, this is a function, this is a conditional; go make a relativistic kinetic energy calculator”.
And, if you want to learn quickly, that’s all you really need! You certainly don’t need to take a uni module to do it. You just need to know where to start.
Recently my housemate chose a dissertation topic which required knowledge in C#. He didn’t know C# at all, and he was wasting hours reading tutorials. I told him the same advice I followed myself when learning it: Think about how you would do the operations yourself, break it into steps, and if there’s any step where you don’t know some key technique, google it. Someone has had your problem before, and some helpful person has uploaded a solution to it, and it’s easy for you to find it.
Now, it’s all well and good me saying this, but you still don’t have any idea where to start. You need to know some key things to make a simple game in a command prompt (which is a great place to start):
- Conditionals (if, else, switch)
- Loops (for, while)
- Variables (ints, floats, bools, strings)
- How to use an IDE.
Not only is Visual Studio incredible, but switching language will be a great way to get you out of your comfort zone. You’ll be at a point where you’ll need to be googling lots of basic things to work them out for yourself, and this is probably the best way to learn. These skills will really be required later on.
VS has something called, “Intellisense”, which is an absolute lifesaver. If you’re typing a variable name, it will optionally autocomplete your word. Later on when you’re typing things like GetComponent frequently, this saves huge amounts of time. You can also hover over a variable and it’ll tell you what kind of variable it is.
And, perhaps, the best thing about Visual Studio 2010: When your code isn’t going to compile, you don’t have to wait until you click the compile button to be struck by 10 error messages. It underlines your errors for you as soon as you make them! I’m currently analysing data from the Tevatron for lab, and I’m forced to use notepad2 with CERN’s own compiler, Root. I spend half my time fixing compiler errors from stupid mistakes.
So first of all: come up with a game idea that’s simple enough for you to code - something whose core game mechanic doesn’t have any physics. It can even be a simple clone of something that already exists if you’re out of ideas. Anything that you will find compelling and will reinforce what you know, and teach you some new ideas will do.
To start, it would probably be easiest to code one basic mechanic from an RPG or a puzzle game.
For example, the first thing I coded was a very simple RPG overworld system in an MS DOS console. It’d generate an ASCII map from a 2 dimensional integer array (where, e.g. “-1” would be a wall, “1” would be the player etc.), in which you could move your player around, and bump into walls. This is a good exercise for learning basics, and there will be some things you need to google (like how to take keyboard input, how to wipe the console and publish the map again whenever an action is taken, etc.).
One important command you’ll need to learn for this, for instance, is Console.Write(), which will print to the console.
I then added a system for mana diffusion. An invisible 2D float array of numerical mana values was present, and mana would diffuse from areas of high concentration to areas of low concentration, so when you absorbed mana there was less left around you to absorb. It was also a nice visualisation of the Zeroth law of thermodynamics in action too.
After that I coded my first version of my game, Rotation Station. Back then, it was just a simple connect-4 game, but you could choose how many pieces you’d need to connect to win and every n turns the whole grid rotated 90°, letting gravity contort the playing field. Next I added some simple powerups like rowblitz, gravity shift, the ability to spawn blocks etc.
Make a new project. Make it a C# Console. At this point, if you’ve never used an IDE, you won’t really know what you’re doing. This is where looking at a hello world tutorial might help, but remember: if you’ve done Codecademy, you already know loops, conditionals, variables and functions!
First, turn on displaying line numbers:
Now work in “main”. You’ll need to work out how to use Console.Write() and Console.Read(), in order to get some input and output, which Google will assist with. Once your code is ready, compile it and it’ll run in the command prompt. To stop the console from flashing and immediately disappearing, press Ctrl+F5 to compile, rather than just compiling. This way it won’t immediately shut down after it’s finished.
Once you’ve fiddled about, try using 2D arrays (i.e. int[,] arrays) to make your own system of displaying a game map or board in ASCII with cout. You should be able to build some kind of basic game functionality.
Once you’re happy with this, it’s time for the next step up: Get Unity3D.
Unity3D is an incredibly intuitive game engine. It takes all of the difficulty out of representing things graphically, and has lots of incredibly convenient built in classes.
I’ll go into more detail on starting out in Unity for the first time in a later blog.
If you encounter any issues along the way, feel free to contact me; I’ve been there. But for the most part, you should be able to troubleshoot any issues or gaps in your knowledge with Google. You’ll learn to love Stack Overflow and Unity Answers.
ETA on learning all this? A couple of months, tops, if you’re motivated. It’ll take a bit longer once you start working in Unity, and I’ll discuss timeframes you can expect for that too.
Also, stay tuned for the next installment to this series, where I’ll discuss in depth where to start if you have real difficulty creating your own 2D artwork, how to use motion to make static gameplay more aesthetically pleasing, where to begin if you want to write your video game music and getting started from coding in a console to coding in Unity3D. The next article will be about art, where I'll show how to go from the previous screenshot to have something that looks more like:
with no prior knowledge of 2D art design within a month.