Simon J McDonnell

Creating cool stuff

Sprite Animation

I’ve been working on Sprite Animation a lot in my home engine (a post about it is incoming). I thought I’d take the time to explain where I began and where I ended up.

During my first iteration of the engine I had a completely separate component than SpriteComponent for animating things. It was inventively called AnimatedSpriteComponent. This would form the basis of my later implementations, but it had some pretty serious drawbacks. One of which was that making an animated sprite with this method meant you would have a different sprite for every single animation you wanted to have. This would be pretty wasteful, and would get really annoying trying to juggle the animations on and off at the correct times.

On my second (and current) engine iteration I began doing things a little differently. I decided to make all sprites animated by default. They could be passed some optional parameters on creation that would give the relevant animation info. This had a similar drawback to the first iteration, where each sprite could only have one animation that was either on or off. This would make it cumbersome to use. Also it took different textures for each frame, which is a big no-no as switching textures is really expensive, so all frames for an animation should rightfully be in one texture.

The most recent improvement to this system came with the introduction of a middle-man between Texture and Sprite – Images. This is also when I introduced support for Texture Atlases. Images are essentially a way to pick a single picture out of a big texture packed with a lot of different ones. Images made it so I didn’t have to have different textures for each animation frame, I just had an Image for each instead.

My second improvement was making animation something the sprite class had no active hand in. Up till now all animation has been done in the SpriteComponents Update method. I decided to take the animation functionality out of SpriteComponent and made a new class out of it – AnimationClip. Now each Sprite has a collection of AnimationClips which are referenced by their names. AnimationClips can take a start frame and a number of frames, which they will then attempt to load in order.

E.g. spriteComponent->AddAnimation(“animationName”, 6, “testAnimFrame”);

It will then attempt to load testAnim1, testAnim2,…testAnim6. Alternatively you can just supply a list of as many frames as you want.

E.g. spriteComponent->AddAnimation(“animationName”, 5, “testAnimFrame1”, “testAnimFrame2”, “testAnimFrame3”, “differentTestAnimFrame4”, “testAnimFrame5”);

You’re then able to reference these animations in an easy way:

That’s pretty much where I am now. I’m pretty happy with my current system but there are definite improvements to be made. Right now a Sprite will just play whatever it’s active animation is if it has one. I’d like to add both default animations, and triggerable animations. So you can set a sprites default animation, and it will play that one whenever it doesn’t have anything else to play. This will make the introduction of triggerable animations easy, as they will just play for however long you want before transitioning back to the default.

Also it’d be cool if you could set event callbacks at specific points during the sprites animation, so you could, for example, set up the sound of a footstep to play each time a character took a step. ALSO it’d be nice if the timeline of animations worked in such a way that you could play them backwards by just specifying a negative speed.


I guess what I’ve discovered is that sprite animation is a very interesting thing to work on, I can see myself being distracted by it for quite a while.

Apologies for the bordering

Apologies for the bordering

Dark Souls, Or, How Ornstein and Smough are stupid fucking shitheads


Same way I often feel while playing

So I’ve been playing Dark Souls recently and I want to talk about it.

Dark Souls is a game that rewards repetition. Repeat the same mistake with harsh enough consequences enough times and you will learn to adapt. You can only die to surprise attacks when emerging from doorways so many times before you start inching out of each one with shield raised and thumb hovering over the back-step button. Even the combat is based primarily on repetition. It’s about learning attack patterns and telegraphs. Bosses can be very intimidating, until you learn how they work, when they’re weak. Then it’s just a matter of exploiting that weakness successfully enough to win.

This repetition-based design doesn’t preclude skill, by the way. It takes a lot of skill to exploit these weaknesses on a consistent basis. Maybe Dark Souls then teaches us that skill is simply the accumulation of repetition to a certain point, beyond which you become “skilled.” This is as opposed to skill inherently requiring some natural talent. This is actually something I fervently believe; that anyone can become good at anything with enough practise. This comes with limits of course, someone with nerve damage in their hands is unlikely to become a champion guitarist for example. But on average, most people can become good at whatever they pour enough effort into.

Anor Londo is very pretty

Anor Londo is very pretty

My character wields a Zweihander, an Ultra Greatsword, and has done so for most of the game. I don’t feel like that’s bad or even boring because I’m constantly learning how to better use it. I went through a phase of foolishly jump-attacking everything, and had stopped using weaker attacks altogether. I’m now reintroducing them and finding their quicker speed lets me get in and out without getting hit quite so damn much.

He also wears the heaviest armour I currently have in my possession. It’s known as Havel the Rock’s set, and it is (unsurprisingly) made of rock. Not only do I wear it, I do so while being under 50% of my max equipment load, which means I run and dodge roll as daintily as someone in far lighter armour. My end goal is to also have enough endurance to wield Havels greatshield, which is monstrously heavy, while still remaining below this threshold.

Fuck these guys

Fuck these guys

I’m currently fighting Ornstein and Smough. They are….tough. I’ve killed Smough a good few times now, but I always die to Super-Ornstein. Apparently I’m trying to do it the harder way, but as Smoughs armour looks like freeze-dried shit I think it’s necessary. You can only get the armour of the one you killed last by the way, in case you didn’t know.

So a brief summary of the fight. You emerge from the mist gate into this room, with those two at the opposite end. You have to fight both of them at the same time, and when you kill one the other one grows to giant proportions and becomes way stronger. You know, because fighting two bosses at the same time wasn’t already hard.

When I started writing this post I had gotten to the second phase one time. I have since gotten there a few times, but every one has ended the same way, with Giganto-Ornstein at >50% health. Every time I play has now become a repetition of the same thing. I fight the two knights that are directly in my way, then run past everything else till I get to the boss room. I will then either die before killing Smough, or kill him and die to Big Daddy Ornstein. It’s becoming sort of depressing.

I would like to progress with the game and see more areas, but I’m stuck on these guys. God I want to beat them, I want to beat them so bad. But if I want to finish this then the only way forward is by ramming myself against this until I internalise their patterns enough to fuck them over.

Then I will pluck the armour from his flesh, piece by piece, savouring the feel of it’s cool caress against my skin.

Then I will be the Ornstein, and the Ornstein will be me, one Ornstein, unending.

Yes, yes, yessssssssssssss

Game Backlogs

I own a lot of games. Like, a lot. I have about 300 just on my steam account. I’ve come to this number through a mixture of steam sales, bundles, and bad decisions.

There’s a weird kind of paralysis that comes with having a ton of games to choose from. It gets very hard to choose one of the other, so you end up installing more and more, but never playing any of them. In a way it was better when I was a child and a teenager. My choice of games and my income was so much more limited that I ended up playing the small amount of new games I had to completion, rather than getting more before I’d even finished the ones I had. Now I own more games that I’ve never tried than I do ones I’ve completed.

Buying new games is something I now have to guard against. I’m drawn to the allure of something new, something that I’m sure I’d enjoy if I played it. The problem with that is the feeling can be fleeting. I can want a game so bad because my family and/or friends are playing and talking about it a bunch, but when that conversation abates then I find my urge to play wanes in time with it. This happened with Dragon Age: Inquisition. I wanted it so much when it first came out because my brother Michael was playing it and telling me about all the cool things he was doing. I haven’t thought about it in months, I only did so because I saw a picture of the cover the other day. My life carried right on without a hitch.

It wasn’t like I didn’t play any games during that time. I played a bunch, but that’s sort of the point, I didn’t need any new games; I already had so many that I’d never even touched.

You being to make weird bargains with yourself when you’ve got this much surplus. You say that you can only buy another game when you’ve completed at least one new one from your backlog. Or no new games till next year. One useful things I’ve started doing is to just wait. If I still want that new game in a month or two just as much as I did before then I’ll at least consider it. However if the urge to get it fades away then it takes care of itself, I won’t remember it so I won’t buy it. I ended up buying Sunless Sea this way.

It also affects your playing habits.

I find myself obsessed with finishing games. Red Alert 3 has three separate campaigns; I finished the first one, added it to my “Completed” category on steam, and uninstalled it. Once I had ostensibly completed it I was done. It didn’t matter that there was more fun gameplay there, or that I would enjoy it. Finishing the game had become more important than playing it.

I don’t play “Endless” games much anymore. Civilization 5, Eador, Crusader Kings 2, Don’t Starve. Or rather, I will generally play them for a length of time that I equate to getting my moneys worth out of them. When choosing a new game to play it’s imperative that it count towards reducing my backlog, and endless games are timesinks that distract from that. This is independent of how enjoyable the games are. I adore Crusader Kings 2. It’s a wonderfully enjoyable game that I sank a lot of hours into it when I played it. It doesn’t bring down my numbers though, so I don’t play it now.

I’ve become a slave to my backlog. It dictates what I play and what I buy.

This isn’t all bad. Curtailing spending is something I’m always looking to do (early retirement here I come!), so it does serve that purpose. It’s also very clearly not the worst problem to have. “Oh no, I have SO MUCH media it’s hard to consume it all!”

There’s a lot of weird thinking when it comes to game backlogs. Now, if you’ll excuse me, I have to play a game (but only one I haven’t played before).

Drawing lots of things on a computer

So I’ve been worrying about how well I draw my sprites in my little home game engine. I began researching it and began to learn about something called Instancing, which is a way to draw a whole lot of things without killing your computer.

For the non-technically literate the basic way that you draw something using a computer is by setting up all the data for the thing you want to draw (position, what image it is, size, etc). You then send that data to the video card on your machine. Finally you tell it to draw the stuff you sent it. Simple, right? Not quite.

Sending things to the video card is hard for the computer, and drawing things is even harder. So a key part of rendering is figuring out ways to minimise both the sending of data to the GPU, and also the amount of times you ask it to draw something. A great way to do this would be fewer draw calls. I mean, if you were drawing the same thing over and over again, just in different positions, it would only make sense to do it in one draw, right? Right. Instancing is a way to do this.

So many!

So many!

The basic idea behind it is to hand the GPU a bunch of data that’s the same for every instance you’re going to draw, lets call it SAME_DATA. This would be the shape if it were a 3D object, so all the things that describe that object, like the position of vertices, texture coordinates, etc. You then also hand it a bunch of data that holds the things that are different for each instance, lets call it DIFFERENT_DATA. When it comes time to draw something, the GPU will draw the SAME_DATA stuff the same way for every instance, but will keep peeking into the DIFFERENT_DATA to grab stuff that’s different for each one. So that way you can get the same exact 3D model drawn in a bunch of different places using only one draw call.

So that’s how it works. I have decided not to use it just yet.

There are a couple of reasons for this.

The minor reason is that there might be some evidence that it’s not that helpful unless you’ve got an absolute ton of things being drawn.

The major reason is that I don’t want to. I’ve been messing around with the rendering side of my engine for a while now. I most recently added support for texture atlasing and reworked how sprites operate and how they animate. This has had me make several significant changes to how the rendering works. I want a chance to solidify what I’ve done before I start doing another major overhaul. There’ll be plenty of time to improve it later, but it’s not even currently a problem, so it’s on the backburner for now.

Start as you mean to go on

Hi! I’m Simon McDonnell, I’m a game programmer who is currently living in Ireland. In the past I have completed a degree in Computing in Game Development in DKIT, and have taken part in the international games development competition, Dare to be Digital. I used to work for Tag Games in Dundee, Scotland, and am now working for another games company in Dublin, Ireland.

I really like programming (you may have guessed), and a decent chunk of my posts will be about things I’m working on either at home or at work. I’m also into game design and development (the surprises keep on coming!), so expect to see a smattering of posts on those topics as well. Apart from games I’m also an avid reader, primarily of genre fiction. I like writing as well, so don’t be too alarmed if my posts come in the form of english sentences, as opposed to the alien hieroglyphs that come so much more naturally to everyone.

I’m not sure what my update schedule will be for this website, but I have some posts in a backlog so feel assured that there’ll be something new here on a semi-regular basis.