This is part 1 of an ongoing series of articles.Part 1
- "Choosing a language, additional libraries and development environments."Part 2
- "The Wall."Part 3
- "Design and distillation."Part 1 - "Choosing a language, additional libraries and development environments."
Hi, my name is Leigh. I've already posted a hello on 'The Obligatory Introduce Yourself Thread
' - Its a riveting read and contains a spiffy picture of me as well! At the bottom of the post i talk about wanting to be a game programmer and starting to write my own game so for no other reason than to punish you all, I've decided to document this effort and make it available for all to read.
From time to time, probably on a weekly basis, I'll drop by and write up a chunk of whats been going on since the last time i was here, I'm not sure what kind of detail I'm going to go into but I'll start from the beginning and provide links to anything interesting I've learned or used. Its important to note though that while I'm a complete C++ and game programming novice (read - never ever done it before,) i am a commercial PHP programmer and already have a pretty good grasp of many of the fundamentals of programming in general.
Before i even started coding, there were a bunch of decisions i had to make;
- Which language should i use?
- How does that language lend itself to game development?
- Do i want to develop with cross-platform independence in mind?
- What tools are available for my chosen language?
Realistically, I'd made my mind up already. Being mocked by certain friends that PHP wasn't a real language (when clearly, it is
) meant the only acceptable choice was C++
. My reasoning was infallible, real games were made in C++, hell, Windows was written in C++ (maybe my logic was faltering now..) but generally, its accepted C++ is man enough for pretty much anything.
I've found there are many considerations even when you've chosen your language. C++ is 28 years old, nearly as old as me, certainly at the time it was created there were barely displays able to represent graphical output let alone machines powerful enough to have games made and run in the language, it is infact a very generalised solution that specialises in very little and requires any number and combination of external libraries to extend its abilities, making it suitable for game development.
My next choice was which API
should i use with C++?
This choice seems to be subjective, certainly there are proponents for all of the available choices and most if not all allow the full development of games with varying degrees of difficulty. From my research, the main contenders are;
Commercial development treats DirectX as the norm for Windows games, it is an all-in-one solution that provides advanced 2D and 3D graphic capabilities, sound, networking and input handling and thanks to it being the standard, has plenty of in-depth documentation. I decided that i was going to be hardcore and dive straight into C++ with DirectX and shortly after trying for a while, i gave up and re-evaluated my options. DirectX is a pig for beginners.
The other commercially recognised API is OpenGL, this is however useless by itself and needs to be used with another API, SDL seems the best fit for starters, but OpenGL is again quite complex and not recommended for first-timers. It's worth noting that OpenGL unlike DirectX is cross-platform and has been ported to many platforms. Careful adherence to code standards and a mind for the differences in target platforms will make porting your code to another operating system or computer platform entirely possible.
One of the interesting possibilities with OpenGL (and i guess DirectX,) is that you can build a game engine that uses polygons and textures but on a 2d plane, this has the advantage of flexibility, reducing possible restraints of a tile-based 2d engine and allowing for treatment of the graphics with shaders and lighting techniques available to 3D games.
I've included Allegro though ultimately i chose not to use it, as like SDL, it is a complete set of libraries that will enable full development of any type of game you might want to make. Allegro has plenty of documentation and is as learner friendly as you'll get with C++.
I chose SDL as it is cross-platform, free and at least in Windows, it works as an abstraction layer
for DirectX7 (which means it'll work on a wide range of hardware with acceleration,) it has plenty of decent tutorials and documentation is easy to understand. A nice bonus is that when you get more knowledgeable in programming, you can use SDL as the companion API for OpenGL.
With my language and its API decided upon, the next step was setting up a programming environment.
I actually work in a production environment thats far more complex as it turns out, than C++. It really is a case of 'What you don't know seems bloody complex.' But in fact, its not.
First things first, C++ is a compiled language. You type your code into a text editor (which could even be Notepad or vi if you liked,) and its then compiled into an executable file that can be run. Most of the time, your going to want an IDE
, an Integrated Development Environment because while you can use Notepad or vi and compile your source code on the command line, its hard for beginners and pointless because there are any number of IDEs that do all the hard work for you.
In work, i use Eclipse
, more specifically, PHPeclipse
, a plugin for Eclipse that provides a tailored environment for PHP. Eclipse is AWESOME and i really wanted to use it for C++, but though there is a C++ plugin called Eclipse CDT
, it lacks many of the smaller touches of genius present in the PHP plugin, and is as it turns out, a pig to configure properly.
Other options include;
There are of course others, but these were the ones I've looked at. I ruled out all but Visual C++ 2005 Express Edition because there are slight differences in the implementation of the different C++ standards, and while Microsoft's policy of 'Embrace and extend' has resulted in the majority of alterations to the C++ standard, it has an environment that 'just works' and also has massive online documentation and support.
It is important to mention that there are considerable limitations to the Express Edition of Visual C++, they are listed HERE
, though based on my currently limited knowledge and from talking to others, i do not believe this precludes complete game development.
From my experiences in handling a massive codebase (18mb of source code over 1557 PHP files) with up to 10 people working on the same thing at the same time, i've become a big fan of version control software. From what i have gathered in various forums, so are many game developers. We use SVN
at work and we interface with it through a windows shell app called TortoiseSVN
, its perfectly suited to C++ development and i haven't considered anything else though as usual, there are a full set of alternatives
Subversion allows you to save 'snapshots' of your code at any point in time, comment on that snapshot, revert to earlier snapshots and browse previous versions of your code. This is great for when you've broken something and can't fix it, just revert to a previous state. Think of it like Windows System Restore feature, but for your code.
From the programming side of things, thats basically it, you can start up with that, and thats where I'll pick up in my next installment.
For clarity, i present the relevant links below for the environment i have setup;
For those who want to actually try coding, here is a decent C++/SDL tutorial site
that has help for Visual C++ 2003 (which is pretty much the same as 2005)
I welcome comments, i may not be able to answer questions if they are too technical (just yet!) and in what i suspect will become a tradition, please accept this picture of an amusing cat as a token of my love;