Coding update

Published June 25, 2007
Advertisement
Time for a coding update. Amongst all the other things I've been doing lately I'm also currently upgrading the internals of my sprite engine, Diagonal. In the creation of Brixtar and the aborted attempt at a MAGIC game I've pinned down a number of architecture flaws that needed fixing.

Firstly, I've been inspired by all the singleton debates raging on this forum to desingletonise my system, as in nearly every case they weren't needed. I've got a few things that need global access and a lot of things that need only a single one to exist, but nothing that needs both.

Secondly, I've upgraded the sprites with a bit more functionality; sprites can now be put into groups and manipulated as a unit. I've made a new object type called a "sprig", short for sprite group, except it's a bit more fundamental than that. Sprites themselves are defined in terms of the sprig class, and I'm envisaging the entire game will consist of a series of "sprig trees"; groups clustered within groups.

While in essence this change is pretty simple, it did require a complete restructure of the internals of the sprite system and several attempts at the proper way to define the relationship between sprigs and sprites (having the graphics module own the memory of both of them makes things a bit tricky), but I think it's working now.

The basic idea is that sprites (or sprigs) can now specify their position relative to a parent sprig. If the parent changes location, so does all of its children. This will make it simpler to implement many features, such as cameras (just put all the game sprites as children), text boxes, windows and any other game elements made from many sprites.



This simple test shows a bunch of rotating disc sprites decreasing in size, with each one in the chain defined in the frame of reference of the previous. Since every sprite is rotating, the result is a spiralling effect, with the discs at the end moving along at a fair speed.

Now I've got the basics done, I can integrate these improvements into the text module and start working towards the GUI system.
0 likes 4 comments

Comments

Ravuya
A scene graph is probably a really good idea for a sprite engine; eventually I'll have to build one.
June 25, 2007 11:00 AM
Trapper Zoid
Quote: Original post by Ravuya
A scene graph is probably a really good idea for a sprite engine; eventually I'll have to build one.

Ah, so that's what it's called! I knew this technique needed to have a name, but I guess given my lack of interest in 3D it didn't come to me. I should have figured out the "graph" part, even though "tree" is a fair bit more accurate.

June 25, 2007 06:11 PM
Ravuya
Well, trees are just directed graphs.
June 26, 2007 03:24 PM
Trapper Zoid
Quote: Original post by Ravuya
Well, trees are just directed graphs.

Yep, but a distinct subset and I like to be precise [smile].

June 26, 2007 06:52 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement