I thought I should try my hand at writing something basic to help people learn to make simple games.
A computer operates on computer language, machine code. You can code a computer using only machine code, and that is what they originally had to do. To make things a bit easier, different coding languages has been developed that are readable for humans. Code that is written in such a language can then be transformed to machine code that a computer can use. To make it more complicated, different operating systems use different machine code. Often you can translate code written in a coding language to different machine language, sometimes a bit of tweaking can be needed.
I'm here going to use the coding language Python.
To make things easier you will in coding use blocks of code, functions, that can be reused in different parts of your code without have to write the whole thing every time. A number of general functions comes directly with Python. More specialist functions can be collected in separate libraries, which can be added to your program.
Pygame is such a specialized library that will provide useful stuff such as creating a window for your game, providing tools for handling graphics, playing sounds and handling input from keyboard and mouse, to mention some of the basic things. A bit further on we will be using that library.
There are also game engines that provide more tools for the programmer, which can speed up the process of making the game. The providers of some such engines will claim you can use those engines to make games without knowing how to program. That is not quite true, unless you are making games within the limited restrictions that that engine is geared for. If you are going to do anything outside that box, you will have to do coding in some sense. It pays to understand the basics of coding.
It might technically be true that you do not need to know how to program provided on how you define 'program', but it would at least be misleading in that you still have to provide orders to the computer in a way that can be translated to machine code.
I am in no way an expert on coding but I have been doing it for a while, on a strict amateur - noncommercial - level, using different languages and different engines. I'm almost new to Python and to Pygame (though Pygame is built on SDL, that I have used before). I hope that I can in this, relate to the beginner in a way that might be more difficult for an old pro. On the other hand, I might not always stick to 'best practice' and even do things the wrong way.
On that note, let us get started.
You should start with installing Python.
Go to www.python.org/downloads/
Download and install the latest version. I'm using Python 3.7.0.
I'm using windows (win10). If you are using Linux or Mac you need to install versions for those OS, there might be some differences in editors and such, but the coding will generally be the same.
Create a folder in which you will store your working files. You could name the folder 'Python' or whatever you find suitable.
Create your first working file in the folder as a txt-file. Rename it "HelloWorld.py". When the computer ask you if you really want to change the extension, say yes. If the option 'Hell, yes!' is available, chose that.
Right-click the new file and chose to Edit with IDLE. Idle is an editor that comes with Python and which you can use to edit your code and to run the code.
Let us start with the traditional first code.
Write the following in the editor.
Save the file and then run the code.
You can save the file under File > Save (ctrl + S) in the toolbar and run the program with Run > Run Module (F5).
If the program writes out the text ‘Hello World!’ you have successfully run the program and you are now a coder. There is no going back now.
So go make a game.
Well, ok, there might be a few more things you might need to know. Let us get back to some of that in part 2.