Hitting the Pool

Okay folks, it’s summer and it’s the perfect time to hit the pool! This being a game development blog, you can probably guess that I’m not talking about the filled-with-water kind of pool, but rather memory pools. Oh yeah, programmer puns. They’re the best, right?

All joking aside, pools of preallocated objects are a basic but very useful structure for controlling memory allocation in games. The basic idea is that, instead of allocating (“new-ing”) an instance of an object just before you use it, you preallocate a set number of objects ahead of time and store them in a list (pool). Later, when you actually need to use an instance of the object, you grab an unused instance off the list and initialize it with the relevant data.
Continue reading

Multiplatform Deep Copy in XNA

This week on Game Dev Without a Cause, we’re going deep. Deep copy that is! Okay, you really have to be a programmer to find that all appealing.

You may not need to do it often, but when you do it’s really useful to have an easy deep copying solution on hand. As simple as it is conceptually, it can be surprisingly difficulty to find a general-purpose way to perform deep-copies on arbitrary collections of data. It can be especially difficult with XNA because the Xbox 360 doesn’t have the full set of features available to the Windows version of the framework. Sure, it’s easy enough to write deep copy logic for simple structures, but who wants to be stuck updating Clone() functions or the like every time they add a member to a particular class.
Continue reading

Debug Line and On-Screen Log Drawing Components for XNA

LIke the scaffolding around an under-construction building, it’s important to have the right structures in place to aid your work even though you won’t need them once the job is done. In the case of games, this takes the form of the various bits of functionality used to debug games as they’re being built.

In the hope that they prove useful to other XNA developers, I’d like to introduce a couple of GameComponents that I use to provide debug functionality for my games: LineBatchComponent and ScreenLogComponent.
Continue reading