Aaa! So you've decided to totally lose your mind and write games that work in Linux! Welcome to Linux, chances are you decided to get Ubuntu since you have absolutely no idea how to use Linux. It seems like you probably have made games for windows before in c or something, and have probably never heard of GCC, SDL, or OpenGL. No! With you it probably has always been DirectX to the death! I might be overreacting and you might have knowledge of any of the above, but if that's the case then you're going to be much better off~ If you meet the above minimum requirements, then this tutorial is for you. To make sure that this tutorial works like it should and so that you don't have to open the terminal so much, I highly recommend you get Ubuntu.

After you've played with the system a bit and got your video card working... You didn't? Well just click on the Hardware Drivers manager as shown in the picture:

You'll see a list of drivers, try and enable your video card if it isn't already enabled. You may notice a significant increase in the performance of the GUI now. Alright... Now what!? I think it's best to start at the bare minimum and compile a simple hello world program. Compiler? What compiler? There may not be a Microsoft Visual Studio in Linux, but it came with GCC with c and c++ versions. Let's stick with c to keep it simple. Anyways, go ahead and make a new folder called hello:

Hello World

Alright, let's take GCC for a spin! Open the folder, right click, and create a new file and name it hello.c as shown in the picture:

Double click on it to open the edit and put the following hello world program inside:

Alright! Er... Now we need to get GCC to compile and run this thing. Linux supports some weird batch files called Makefiles, which are sort of smart .bat files as you are used to in Windows. There's much you can do with a Makefile, but it basically follows this syntax:

<target>: <list of files to depend on>
<command>
<command>
...

The target is a name, for exmaple "compile". After the colon you need to press TAB and enter file names, sperated by a space. If these files are modified from the last time the command was run, the commands below execute. The commands are simple command-line terminal commands. Simple? Well, create a new text file called "Makefile" and don't add .txt or anything, it's just called Makefile. Put the following code in it:

compile: hello.c
gcc -c hello.c
gcc hello.o -o hello
./hello

Don't forget to press enter at the end. Basically, this file means that if "make compile" is typed in the command line, then if hello.c is modified from the last time, it should run the commands below. gcc -c <list of .c files> compiles the files, gcc <list of .o> -o <name of program> puts them together and ./hello executes the program to test it. But... How do you test it? There's a nifty shortcut built into the text editor you are in right now (GEdit to be sure), just Go to Edit, and the Preferences, click the Plugins tab, and then check External Tools if it isn't checked already. The following should be available to you as shown in the picture:

So click it and... What!? stdio.h is not found? How did you manage that!? We need to actually add... *sigh* the standard c library manually. Click on the following shown in the picture to get to the Synaptic Package Manager:

Click search and type "libc6-dev" or "libc" or "libc-dev" until you see a libc-dev package to install. Click the box, mark it for installation and apply changes. It should look something like this (but not exactly):

Hello SDL

That's how you add libraries and things directly. Now go back to the makefile and click the tools->build again. Yay! It tells you "Hello, world!" finally. It's been a bumpy ride, but I'm going to finish off with an application that opens a blank SDL window. SDL is a system for simple 2D games, and it's perfect for getting used to Linux game programming. Go ahead and install the following package like you did before, here's a picture so it did happen:

Alright, make a new folder called "sdltest" and create a new file called sdltest.c with the following code (notice how GEdit highlights c syntax^^):

Notice the lSDL? That has to go BEFORE the other stuff because GCC has (at least for me) placed them all in order. Alright, just to make sure, my folder looks like this (I have already tried out the program as you can see from the extra files... you should tools->build too...):

And finally, we've come to a landing! The final result is a black window of SDL:

Conclusion

From here, now all you have to do is learn SDL. There's nothing else Linux-related you have to worry about anymore for the time being, but keep an eye out for any more Linux Tutorials for such things as using the tools and libraries to make games, and how to build a Windows version of your game (it's actually sort of the same way, only with a Windows port of GCC).

Before I let you loose, let me give you a list of tools you can use to help you make games. You can search for these under Add/Remove in Applications. Installing them is easy.

- GIMP (probably already installed) for making images, it's no Photoshop but it does the job.
- Audacity for editing sound files.
- Blender for making 3D models.
...and so much more, browse their software catalog under Add/Remove.

Also, take a look for what they've got for IDEs, I'll use GEdit's build shortcut and makefiles for the sake of simplicity for any demos I make, but using an IDE allows you to organize better your game projects. I hope you enjoyed yourself, and have fun with Linux! Try playing a few of the games you can find under Add/Remove, hehe

I already submitted part II, and hopefully a moderator will accept it soon. In there you work with SDL to create a swarm of pixel dots. Anyways, to answer your question, SDL must be installed separately and I teach you how to install packs using the Synaptic Package Manager in this very tutorial because you also have to install libc-dev (libc6 / libc6-dev / ect).

I'm a Windows user so I'm writing as though you have only slightly less of an idea of how to use Linux than I do. Using the operating system isn't that important in game programming since once you've got your graphics open, that's all you need to deal with.

I've read other Linux game programming tutorials and they're all mostly awful unless you're a *nix junkie. For the last time, the terminal is not awesome! I might be able to go through the entire series of my tutorials without ever opening that stupid thing. The whole point of an operating system that has windows and graphics is to make everything easy to use. We're GUI users and we demand a GUI, so I'll stay away from that wall of text garbage.

What I cover in the next tutorial each time is unpredictable, I may cover anything from sound to tool programming. The only criteria for this series is that you've started with part 1 and went in order, then you should be fine.

I'll use SDL for the tutorials for it being easy, but of course I do encourage all you new Windows to Linux game programmers to give other libraries a try. Note that you should be dual-booting and you might actually develop the game in Windows, but compile in Linux to test so you have 2 versions of the same program. When part 3 of my tutorials are accepted, I teach you how to do that.

For me, one amazing thing about linux is, easy to use libraries and API but ultra complex configuration scripts to compile your program due to too many libraries. Good tutorial, I don't feel like going in my docs folder and reading library documentation.

When giving your game to people, sure it's nice to give them the source codes but for the LOVE OF WHATEVER IT IS YOU BELIEVE IN please provide just the program we can click and run. I absolutely refuse to support any sort of Linux software that REQUIRES me to compile it using the terminal. If I have to open the terminal, no matter how good your program is, I will not support it.

So far Ubuntu and the software people provide for it is working well. When/If I release more of this series, the tutorials contain methods that follow the above.

Also probably in high demand, I'll see how to write an installer that installs the files in your Linux system using a GUI just like Windows since not everyone uses Ubuntu's version of Linux. I loathe make-install, we're going to evolve from apes (screw you intelligent design!) that throw stones to a program called "install-game" with some crate file such as "game.dat".

Also probably in high demand, I'll see how to write an installer that installs the files in your Linux system using a GUI just like Windows since not everyone uses Ubuntu's version of Linux. I loathe make-install, we're going to evolve from apes (screw you intelligent design!) that throw stones to a program called "install-game" with some crate file such as "game.dat".

By the way, making a .deb package isn't really that hard and it is preferable to having an installer for your program.

There is a program called "checkinstall" that builds .deb, .rpm, and .tgz packages from your program's Makefile. I wrote a tutorial on making .deb packages awhile back, but you can probably find a better description of the process somewhere on Google.

-------------

Also instead of installing libc6-dev, you should install the build-essential package. Otherwise a nice tutorial.

@WolfCoder
First of all good job on the tutorial, Thanks.
I must disagree on one point, however. The "wall of trash". I LOVE the terminal. And I am NOT a linux guru. If you had a task, say, install "firefox", how much easier would it be to:
#1: Click "Terminal".
#2: Type [code]sudo apt-get install firefox[code]
#4: Press Enter.

(about 10 seconds or so for a slow typist)

OR

Click Add/Remove Programs.
Click in the Search pane.
Type the name of your program.
Select the right one from the list.
Hilight for installation.
Click Install.
Agree to let it perform "the following operations".
(about 20/30 seconds for a slow user)

(The terminal is SIGNIFICANTLY faster than add/remove just for actual visual load as well)