Monthly Archives: September 2011

The October Challenge ( and other gibberings )

0
Filed under GLESGAE, Ludum Dare

Ludum Dare’s October Challenge is more or less under way now.

And in true Stuckie-style, I’m not really ready for it! I still haven’t managed to commit anything of what I wanted to do with GLESGAE back into the github ( though I do have multiple bits and pieces stashed around my machines ) and haven’t quite settled on a distributed VCS.. well, let’s sort one of them out now!

From using both Git and Mercurial ( both at work and at home, funnily enough, ) I haven’t really seen a great deal of difference between the two. Granted I’m not fully embracing what each one can actually do, but from what I can see, they both act similarly enough to me to make the choice somewhat moot.
Git does seem to be somewhat more widespread than Mercurial so I’ll be going with that, I think.. however knowing how to use the both of them is going to help regardless anyway.

Back to the engine then…

As my last gibberish post detailed, I’m going to be plugging a Component System into GLESGAE, and it’s a fair bit of work as it requires all sorts of fiddlings and subsystems which aren’t quite there yet. However, before all that, I still have to finish off what the goal of the VCS trial was all about – splitting up the RenderContexts.

Currently, GLESGAE has a handful of RenderContexts – GLES1, GLES2 and GLX – which all derive from a base RenderContext class. There’s also FixedFunctionContext and ShaderBasedContext which perform the actual rendering themselves and get automatically pulled in with the other ones should they support them. This is silly, as there’s an obvious divide here – PlatformContexts and RenderContexts themselves.
I have in fact split this up on my desktop machine in this very fashion already.. it just needs some more testing and tweaking, and it allows me to define at compile time for specific platforms just how I want things to be rendered.
For example:
I could create a GLES1RenderPlatform, and bind a FixedFunctionVBORenderContext to it. It does what it says on the tin – renders via VBOs. However, as you may be aware, GLES 1.0 doesn’t support VBOs, so for the cases where I can detect that, I replace the RenderContext with FixedFunctionVARenderContext to render through good ‘ol Vertex Arrays instead. Additionally, just to add extra fun, Apple platforms support VAOs – Vertex Array Objects – which effectively save the state of the Vertex configuration into objects to be reused quicker, rather than doing all the manual enabling and disabling of Vertex Attributes – so those cases I’d have FixedFunctionVAORenderContext… and I’m guaranteed to have VBOs on there too.
As you can see, it becomes rather flexible, as each RenderContext only really needs to override the drawMesh function, and perhaps some extra processing to manage VBOs and VAOs where necessary. The ShaderBased Contexts effectively work the same, and can additionally be extended to support later Desktop versions of GL with fun Geometry Shaders and so on.
Additionally, I shall also be creating RenderTargets – which can be either the Screen itself, or an off-screen Buffer… configurable to have your choice of Colour, Depth and Stencil attachment(s)

So, with the October Challenge under way ( and a ton of work to be getting on with, ) here’s my quick and rough schedule for the month.

Week One: System Stuff

  1. Finish off Render Context fiddling.
  2. Increase Platform Support to include Windows, Android and iOS.
  3. Audio.
Week Two: Make The Game!
  1. Get something rendering, moving about, and controllable on all supportable platforms.
  2. Test as many gameplay ideas as I can possibly get away with! ( I currently have three very different game ideas to attempt this month, so I shall be using Week Two to settle on one of them. )
Week Three: Finish The Game!
  1. Finalize as much of the game as I can. Obviously this’ll be a bit more defined during week two.
  2. Effectively have the core game as bug-less as possible.. before going on to implement the potentially vicious parts…
Week Four: Money Makin’ Integration
  1. Integrate any store-based stuff. It is the October Challenge to make $1 (yay, 69p!) after all.
  2. Of course, if doing anything like In-App Purchasing, I’ll have needed to have designed for this in Week Two ;)
  3. This’ll also be the week of submitting it to the various stores and setting everything up in the hope of making that fabled $1!
And on top of this, I shall be doing work related stuff as normal, so this’ll be done mostly at weekends and evenings… even then, two weekends are taken up with other important things… just like a normal Ludum Dare then! Just lasts a bit longer ;)
So, hopefully I shall be posting a bit more over the following month with what I’m up to and so on with the October Challenge… and good luck to everyone else that’s taking part!

Components and Resources and Data, oh my!

0
Filed under GLESGAE

One of the first big tasks I got my mitts into at work was on designing and building a Component-based system with others in our project’s code team, and due to my experience with Database writing, I got given the lovely job of dealing with that end of things.

The database systems have gone through a few changes since then, from a rather query-like system that was very flexible but perhaps to the detriment of causing certain console architectures to have a hairy fit due to the internal database structures, to a more resource managery state whereby the objects the databases maintain are just groups of arrays – or a map, if you will.

Thinking about how to do the components for GLESGAE in a manner that won’t have my hands cut off for plagiarism however, I’ve come up with a slightly different approach.

As I already have a Resource system, I may as well use that. This takes care of the storage and retrieval of both components and entities ( and I can group them as I please due to the whole template nature of the Resource system. )
This leaves the problem of communication.

There are a number of ways of dealing with communication between entities and components, and they all define how the component system behaves. You can have components which are nothing more than data stores, and the entity itself provides the interface to it’s components. This works incredibly well for fixed entity types where you know exactly what components it is going to deal with, and you still retain the component system’s code re-usability for quickly stitching new entities together.
Another option, and the one which I will be leaning towards, is that of the component itself actually containing logic to process it’s own data, and is ticked over by it’s parent entity. This keeps code that acts on data in the same space, further increasing the “smack components together to form an entity” idea that I like so much about component systems, as you don’t need to create an entity interface to maintain it’s components.

So how would the components talk to themselves to get the information they require to update?

Again, there are a few ideas.. from the naive and hacky “just throw a pointer link in, no-one will know!” which not only can cause bad pointer voodoo, but also makes saving state of your component data far tricker than it need be, to giving each component it’s own “mailbox” for others to post messages to it – or in my case, giving each entity a mailbox to deliver messages to it’s components or discard them as it sees fit; much like the Objective C selector gubbins.

How would this work, you ask?

Well, each entity must be unique, whereas components do not necessarily have to be unique ( think of a graphics component which has the same model data.. much more memory efficient just to link that to multiple entities, than duplicate the data inside. ) Therefore, sending messages between entities makes much more sense than to the lower level components themselves. As each component will need to be registered with the entity, it’ll know what components belong to it, and can filter messages as required.

Ah, but how do we sort these messages? and what are these messages composed of?

Well, we can give each component type a unique identifier. This limits us to one type of component per entity, however, so let’s go one further and also tag each component with a unique identifier as well, for those times we may require to talk to very specific components. We also already have a message system built in GLESGAE which works well, as all our events use it. Therefore, every entity becomes an event observer and posts all it’s components’ events once it’s finished ticking them over, which’ll then get fed to each entity during the next frame.
As for what they’ll contain, they can derive from a generic template type so they all inherit common functionality, but can additionally contain whatever extra information is required. Standard POD data in other words.

Is the event system the best option for this though, as wouldn’t every entity receive every other entity’s messages too, regardless of whether they’re for them or not?

True, every entity would receive every other entity’s message with the current event system, as that’s what it’s designed for – updating everything interested in a particular event.
This means that our entity system needs to take some logic out of both the resource manager and the event system to work the way we want it. That and the current event system works more as a callback system in that the events get sent to all observers immediately, where as we want to batch them in this case.

That’s effectively a message system.. messages can be sent as events at any time to the event system, which doles them out to the message system. This then sorts them out on an update call, and feeds the list to whatever has registered themselves with the system. While this sounds like the same functionality as what the event system already does, we want to store every message in a giant array, and give each registered observer it’s own queue. On update, we can then sort the message array and dump each message in it’s correct queue ( or discard it ) and pass the queue on. Having that extra barrier means we can do the sorting procedure on a thread out the way, and send them off when the thread finishes.

So, what are we up to now… we require a message system for inter-component and entity communication, we need entity and component manager systems that sit on top of the resource system and tame it somewhat, and we need shells for the entities and components to derive from. What else can we get away with?

Well, as we’ve decided upon components storing logic, we can really push the component/entity logic a fair bit… an entity is an array of components; a state is an array of sub states; a sub state is an array of logic processes… now there’s a fine-grained state system that can be as granular as we like.
The entity/component paradigm actually works for a whole load of things, especially if your components can process logic as well as store data. And, if done properly, you can serialize the data better too – something which Obj-C does very well as it’s got objects that work in the same manner.

With the Components out the way, we move on to Resources and Data.

As Resource Managers are just typed arrays of raw data, we can just load up chunks of array data without much incident. Have a header that tells the name of the group and it’s size, then dump the whole lot into the resource manager. Nice and easy.
However, pointer data causes issues… pointers obviously won’t be pointing to the same thing when they’re serialized and reloaded, so how do we handle that? You could keep pointer data from all resources you want to serialize, or you can use lookup data ( which we already have for Resources ) which you tag into your serialized data instead of the actual pointer. This does slow down loading, as you need to parse this lookup data and rewire the pointer, however it does work.
Another option would be to look towards a meta data solution, and there’s a few opensource variants kicking around the internet these days. Meta data is very useful, and allows all manner of arcane wizardry on the data to be performed. For the moment, however, GLESGAE won’t be using it as it requires a fair amount of work to setup and implement properly.
Either way, we need to be able to load and save data.. so we’ll require a Resource Data Manager or something.. that can take in a typed array and either fill it from a file, or dump it out to a file.

Of course, to do that we require some agnostic file read/write utilities.. and probably some debugging utilities which I still haven’t done. Still lots of things to do yet.

And that ends what is effectively how I work out what I need to do in my engine! Complete with tense changes and all sorts!
I sit down and think “I need this… how would I implement that? What are the knock on effects? What else can I do with it? What are the supporting systems I need? Do I have them? How do I implement them?” and so on in a recursive fashion till there are no more immediate questions, and I start to write the systems themselves. Madness? Perhaps.. but it’s worked for me so far!

 

As for the Git vs Mercurial experimentation, we’ve actually switched to Mercurial at work so I can evaluate them both for the rest of the month with Git for GLESGAE and Mercurial for work stuff. So that works out, seeing as I still haven’t done what I originally planned to do for this month, and with not much of the month left, it’s getting a bit tight. That and I’ve just added a bunch more work to myself with what the gibberish above describes!

Ah well, keeps things interesting.

Sunrise 2011

0
Filed under GLESGAE, Ludum Dare, Random Gibberings

I was at Sunrise 2011 last weekend, along with Octopi!

That was fun :)
It was our first demoparty, as was probably evident from the fact we were rather nervous and just sortof hid out the road up at the back of the room. For those wondering, I was the one with the two-tone blue zippy hoodie and the multi-coloured space invaders t-shirt, and Octopi wore the red zippy hoodie.

It was also a nice holiday break too.. so during the day, we mostly went wandering around Luton and the surrounding areas, to be back for the events in the evening – or most of them at least ( we were both really knackered on Saturday and missed the prizegiving, but did catch CoLD SToRAGE, all the entries and the start of hoffman’s set! )

I was particularly exhausted as I got to travel to and from the scenic route of Liverpool to Luton…via Dundee! But it was worth it, so it’s all good.

We both really enjoyed ourselves and will be looking forward to attending next year’s party!

And maybe I’ll have time to make a release too :)

 

Also, while I’m here.. this weekend marks the cross over point with me fiddling with git to fiddling with mercurial. Annoyingly, I’ve done bugger all on it.. so I’ll be making a bit more of a concentrated effort the rest of the week. The second half of the month will also see me fixing up the engine in time for the Ludum Dare October Challenge. Or attempting to at any rate!

Right, off to work!