Archive for the ‘Code’ Category

2010-07-04

Various ways to backup

Over the years I have been using several kinds of solutions to backup stuff. Here’s a description of the ones I can remember. Many of them focus on being low-cost, simple and straightforward, but are far from a perfect solution in many other ways.

(more…)

2010-06-29

Unwrapping Values – nearest next angle from a previous angle

So, assuming you have angles previousAngle and nextAngle, and you want to transition from the first to the second smoothly. If it’s like from 358 to 2, a simple linear interpolation will awfully go through almost a full circle down from 358 to 2, when a simple four degree transition forward would have been enough, i.e. you should have been going to 362 degrees instead. So, how to figure out what’s the shortest transition?

I remember hitting against this problem numerous times, always remembering that I have solved it previously but always seem unable to find the previous solution. And I still can’t just write it out by heart.

Once again I had to solve this, so this time I tried to Google for it (“angle wrap delta”), and found out that somebody named Jason S had posted a nice generalization to a related question in Stackoverflow.com.

For your convenience, I’m posting a modified C version of the code here.
(more…)

2009-12-11

Little framework for making prototypes or an LD48 entry

If you didn’t know yet, the Ludum Dare 48 hour game development competition is held again this weekend. In the competition the idea is to make a game using a given theme, more or less from scratch. Basically most people use some small amount basecode to start up with as there’s not really that much point to make every boring bit (like how to open a window) again every time. Besides, a little framework still has less stuff than what fine tools such as Unity3D provides you with to start with. :)

So here’s my little C++ basecode/framework for making a Ludum Dare 48 hour game development competition entry. It should be equally suitable for making some other little prototype games. You’ll need to svn checkout Irrlicht and download FMOD 3 separately. The framework is meant to be used on Windows with Microsoft Visual C++ 2008 (Express Edition is enough).

framework_LD48_tonic_200912.zip

2009-11-10

Code: Tokenizer

Here’s a little C++ utility class for splitting C strings into tokens by given separators. It’s inspired by “tokenwad” taken from Sol’s CFL3, which I have used quite a few times. This version has low memory overhead as it performs only 1-2 allocations (depending if the tokenization is done in-place or a separate copy is needed).

(more…)