Spacefight – Getting familiar with SDL – part 2

SDL 1.2 is a pretty easy library to learn. One web site I cannot more than recommend is Lazy Foo’s SDL tutorials. It’s the best starting point if you’re new to SDL. The tutorials go through a lot of important steps in game development. Putting an image onto the screen, animations, timing and practically everything you need in order to put together a simple game. It also includes instructions about how you set up your own development environment using SDL. So if you are interested in SDL specific topics or guides. Head straight over to Lazy Foo’s web site.

The first steps in SDL

It’s time to try out that SDL is working on the machine. I will try to make SDL to give me a game surface and put a background image on it.

I compiled the test code in the following manner:

In the example I used a BMP image, which is a very ancient and humongous image format. Luckily SDL have extensions, such as SDL_Image. Which supports more up-to-date image formats.

SDL is a very basic library. When it comes to image manipulation, it can pretty much read and write pixel values, draw rectangles, put images on surfaces and update the screen and that’s it. If you need to draw a line from A to B, you need to write your own Bresenham implementation or use an extension. But the most low-level implementations for loading images are there.

As I mentioned in the previous article. I will be using SDL 1.2 for my game. SDL 2.0 is out and has more features and a new type of graphic handling. So its definitely worth a look, for a future project. But I went with what’s most widely used at the moment.

I’ll probably wrap and encapsulate most of the SDL functionality in functions/objects. So it suits the game structure more and pick out more SDL functionality that I might need for the game.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.