HomeMultimedia Game Programming using SDL: Raw Graphics and Event Handling
Game Programming using SDL: Raw Graphics and Event Handling
If you have found yourself struggling with pixel-level graphics and/or user input for your games, this is the article for you. You will learn how to handle these tasks using SDL. This is the second part of a series on game programming with SDL.
Graphics and handling user inputs -- the combination that creates the symphony we call a game. A game world where these two are out of phase ends in cacophony.
In the previous article I discussed the various parameters that go into creating a screen and loading bitmapped images onto the screen. That was pretty high-level as the work was done on structures that represent the actual screen and maps or sprites. But there are times when one has to get his or her hands dirty by working directly upon pixels.
The creators of SDL had already anticipated this requirement and built the capacities to work at the raw graphics level into the core itself. Thus a developer is redeemed from understanding system, platform and architecture specific nitty-gritty about manipulating the pixels. The other aspect of gaming that gives sleepless nights to developers is handling the user input, as the handling of input devices changes from system to system. To remove this burden from the minds of the developers, SDL provides an object-oriented approach to handling the events.
In this article, I will be discussing these two aspects of SDL. In the next two sections, the discussion will focus on pixel manipulation functions and their usages. The final section will focus on input handling. So now that the agenda for this article have been laid out, let's get started.