Two for the price of one!

Published May 18, 2007
Advertisement

Sprites are now working under Windows and Mac OS X. It was an ordeal to get the arcane workings of a PNG loader, PhysicsFS and OpenGL to work together in harmony but it's now displaying pretty pictures. I finally got glpng, a third party PNG-to-OpenGL library, to do the hard work for me after I adapted it to run using PhysicsFS instead of C streams. That makes a total of eight third party libraries just to render that sprite (SDL, Boost, TinyXML, PhysicsFS, zlib, libpng, glpng, and FastDelegate). And that doesn't count system libraries, OpenGL or the standard library.

That particular test shows a single sprite rotating in the centre of the screen. Here's the sprite test code to give you an example of where I'd like to go with this library:
using namespace diagonal;SpriteTest::SpriteTest(){        // get our sprite id.    my_spriteType = graphics::GetSpriteType("testsprite");    my_sprite.SetSpriteType(my_spriteType);    my_sprite.SetPos(0.0f, 0.0f);        // sign up for updates    core::sig_Update.Connect(this, &SpriteTest::Update);}void SpriteTest::Update(){    my_sprite.Rotate(0.1f);}

This example is pretty simple and I expect the interfaces will change a bit as the library develops, but this is an idea of how I'd like to make the graphics system from the perspective of the game code. All that needs to be done is to create a Sprite object (that's my_sprite in this code), set the sprite type you'd like with its name, and on an update call perform whatever actions you need to do on the sprite. The graphics rendering system does all the display work behind the scenes; no call to or from the graphics module needed (except those implicitly included in the sprite, of course).

With a combination of PhysicsFS and some new code of my own I now no longer have to write a config file that states where all the image files are. The code will automatically find all the sprite sheets and load up the sprite names on initialisation.

In a more polished version the game objects won't hook up to the kernel directly; there will be a hierarchy of manager classes to deal with sets of objects in a structured way. I also need to implement the timing code to handle animation smoothly. But I'm very pleased with how this is going so far.
Previous Entry Quick update
Next Entry Basic spriting done
0 likes 4 comments

Comments

johnhattan
Satanist
May 18, 2007 08:05 AM
Ravuya
Ooh. I want to try!
May 18, 2007 08:33 AM
Mushu
What's a Mac?
May 18, 2007 04:35 PM
Trapper Zoid
Quote: Original post by johnhattan
Satanist

I draw a pentacle around my computer every time I cast between variable types.
May 18, 2007 05:00 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement