This post is a portion of Part 1 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.
- Part 1.0: Intro to Game Development
- Part 1.1: Installing Allegro 5 with Visual Studio 2010
- Part 1.2: Your First Allegro 5 program
I would like to introduce a new web series for my blog. The focus will be on 2D game development, specifically with the Allegro game library and will include a mixture of text and video. These materials are being developed and released for a course I am teaching in the fall, but my real hope is to eventually compile them into a book.
Video games attract millions of people, from the occasional hobbyist to the hardcore gamer. I would bet that most people would be hard pressed to find someone they know that hasn’t played a game at some point in their life. These games infiltrate most facets of our daily lives: from the edutainment games we played at school to the games that come with our food at Burger King. Companies that are not the traditional “gamer style” organization are looking for a new medium to interact, advertise, connect, and plug in to consumers. That medium is video games. With so much attention given to video games, it is easy to see why game development is such a huge industry. Every year, more and more money gets funneled into producing bigger, better, and more exciting games. At the time of this writing, the biggest entertainment blockbuster of all time (at a whopping $318 million on the first day) wasn’t a movie; it was the video game Grand Theft Auto IV. This is all great news for game companies, but what does that mean to you? What exactly is video game development? That is a good question, and for it we have an equally good answer. Wikipedia defines Video Game Development as “the software development process by which a video game is developed”. In a nut shell that means code, and lots of it!
Game development is not fun; it’s rewarding!
What I see all too often are people amped up about becoming “game makers”. They have this vision in their heads (probably put there by advertising and “extreme” gamer oriented products) of chugging highly caffeinated soft drinks while wielding controllers like madmen and somehow ending up with a blockbuster like Call of Duty. In short, they think game development is going to be fun. This idea could not be farther from the truth (well, except maybe for the “highly caffeinated soft drinks” part). In reality, game development is rarely “fun”, not in the traditional sense anyway. It takes a lot of knowledge, experience, and tenacity to become a competent game programmer. In fact, most modern blockbuster games require the combined efforts of over a hundred people years to complete. Rarely have I ever been developing a game and thinking to myself “This is so much fun!” Instead, game development provides a tremendous challenge, that when overcome, is incredibly rewarding. There is a certain undeniable feeling of satisfaction when you play a game that you have made; no matter how simple or complex it is. It is that satisfaction that brings the fun to game development. Be prepared to work hard. Be prepared to be confused. Be prepared to be out of your element. I am telling you, if you have an ounce of desire to make your own games, it is worth it. Once you experience the feeling generated by working hard and ending up with a fantastic game, you’ll be addicted.
Be a craftsman, not a programmer
When you make a game, you are in control. Every item that exists, you specifically placed. Every action that is possible has been meticulously scrutinized and calibrated. When it is all said and done, you own something that is truly yours. You are a skilled artist, a craftsman, and the game is your craft. It can be easy to consider game development as just “programming”. That is to say, most people view game development as a group of people cranking out code at high speed until a game appears. While I am sure that some people and companies operate this way, it’s not necessarily the best way. As a game developer, you should always strive to be a craftsman instead of just a programmer. What do I mean when I say craftsman? Being a craftsman is more than just programming; it is bringing art, creativity, and thought to your craft. It means planning your games, and the modules and inner workings of your code before writing a single line. It means viewing yourself as an eternal student and constantly honing your abilities. Most importantly, it means owning your code, holding yourself accountable, and perfecting the art of development.
Why 2D game development?
With so much emphasis on 3D games on most modern platforms, it can feel like the art of good 2D games is backsliding. I will admit that I myself am guilty of immediately thinking of Mario or Tetris whenever someone mentions 2D gaming. I have to take a moment to remember the vast array of recent successful 2D games. Off the top of my head: Angry Birds, Braid, Limbo, Marvel vs. Capcom series, Kirby’s Epic Yarn, and about a quadrillion (it’s a real word, I looked it up – may be an exaggeration) Nintendo DS, Flash, and Facebook games. Taking a moment to think of it, we can see that there are some really great games still being made as 2D. Good thing for us too, since 2D gaming is much easier to start with than 3D. For starters, the math in 2D development is much simpler than 3D and a lot of it is based on concepts learned in early Algebra. When you are new to game development and programming in general, the math can get a little overwhelming. It is good to keep it as simple as possible to start. Along the lines of simplicity, many of the general concepts you will learn in game development (collision detection, rendering, and coordinate systems just to name a few) are much easier to learn when you are only dealing with two dimensions. If your passion is 3D (and only 3D) development, don’t be put off by this series either. Many of the development and game concepts you will learn in 2D in this series are easily transferred to 3D. For instance, while the rendering and game logic can change, the general structure and order of a game loop remains the same. It is pretty easy to see that all around, 2D is the best place to start your game development journey.
The Allegro Game Library
In this series, we will be using something called the Allegro Game Library. In olden times, when you wanted to represent something graphically on a computer screen (like, say, a video game) you had to program all of the low level functionality yourself. This meant working directly with the operating system and video / audio / input drivers to make your game work correctly. A bunch of time was spent figuring out the operating system specific function calls and getting everything to work correctly. Porting from one OS to another was a complete nightmare. All in all, things were very difficult to maintain. Enter Allegro. At first I was going to describe Allegro, but the website (http://liballeg.org) does such a great job, I felt it was a shame not to use it:
“Allegro 4 and Allegro 5 are cross-platform, libraries mainly aimed at video game and multimedia programming. They handle common, low-level tasks such as creating windows, accepting user input, loading data, drawing images, playing sounds, etc. and generally abstracting away the underlying platform. However, Allegro is not a game engine: you are free to design and structure your program as you like.
According to the Oxford Companion to Music, Allegro is the Italian for «quick, lively, bright». It is also a recursive acronym which stands for «Allegro Low LEvel Game ROutines». Allegro was started by Shawn Hargreaves in the mid-90’s but has since received contributions from hundreds of people over the net.”
Essentially, Allegro handles all of that low level, operating system specific, ridiculousness so that you can go about doing what you want to be doing: making games. The super cool thing about Allegro? It works for just about any C++ compiler on the three major operating systems (Windows, most distributions of Linux, and iOS). This means you can work in any environment that you choose and porting your game to any and all operating systems is a breeze. The end result is that you get to worry about learning to make great games, and not about all that behind the scenes stuff.
What you need to succeed
While this series is aimed at true beginners, there are some requirements.
- A very basic knowledge of C++
Introductory C++ programming is outside of the scope of this text. That being said, I have been very careful not to include any topics that would not have been taught in any introductory C++ course (or that could not be easily learnable from a few internet tutorials). If you’re not sure if you have the required knowledge, see the side bar.
<Note: Topics that are generally used in this text are: variables, functions, structs, and arrays. If I hit upon any topics outside of this list, I will briefly describe it in a side bar (like this one) and give you information on where to go to learn more.>
- A working computer
You don’t need a powerhouse computer by any stretch of the imagination. The system requirements aren’t very specific. Chances are if it is reliable and runs your favorite compiler, it can run Allegro based games (depending on the game complexity obviously). Speaking of compilers…
- A C++ compiler
Whatever your flavor, you need a C++ compiler and the basic knowledge of how to use it.
<Note: While all examples in this series should run on any compiler for just about any OS, I primarily recommend two Windows based solutions: Dev-C++ and Visual Studio 2010 Express Edition. Both are free and have different strengths and weaknesses. Visual Studio 2010 Express Edition is loaded to the gills with features. While they are not necessary, they can be nice to have. On the other hand, Dev-C++ is lightweight, fast, and simple. This can be very preferable if you are just starting out. The choice is yours. If you plan on working with any other compiler or on any other OS, installation help can be found on the Allegro community website (http://www.allegro.cc) or on the installation and setup forum boards specifically (http://www.allegro.cc/forums/board/setup).>
- Allegro installed
We’ll get to that in the next section…
You will notice that nowhere do I mention needing a specific operating system. Ah, the pleasures of using Allegro.
In following sections, we will look at installing Allegro and getting our first applications up and running.