Stairway to Gaming

March 31, 2017

In game development one of the fun and useful things about being able to program – aside from programming the actual game – is you can build simple custom programs to address specific development challenges. One of the levels I’m currently working on for my Robyn HUD game presented just such a challenge: stairs.

The level in question features two spiral staircases providing access between different floors. Stairs can be rather finicky to model. Ideally, each step should have uniform dimensions and should be a uniform distance above the preceding step. Of course, the total of all those vertical distances needs to have the bottom of the stairs neatly line up with the lower floor and the top of the stairs similarly lining up with the top of the stairs. When you throw the handrails, sidings, and the nosings (the overhang of one stair to the next) into the mix, there are a lot fiddly little bits that need to be modelled to make stairs look good. Especially, when they’re also spiral staircases.

Given that I wanted to play around with the dimensions of the stairs I needed to build – making them wider, deeper, higher, etc. – I knew I didn’t want to manually model the stairs. I wanted a simple tool that would allow me to quickly adjust the parameters of the steps while also allowing me to ensure that the steps exactly matched the overall height that I needed for the level. Being a programmer, I set about developing just such a tool.

Before starting in on the programming, I made use of the great procrastinating tool Google to poke around for builder recommendations for real life stairs. While technically you can make stairs any size you want, there are certain dimensions that are more comfortable for people to move up and down. With that information and some fairly simple geometry I was able to put together my simple stair builder.

[The stair builder interface.]
The stair builder interface.

Being Canadian, I’m supposed to use metric measurements. But there are some areas up here when the imperial system has still been holding on. Since I use imperial measurements when doing wood working, I used imperial measurements in the builder, hence the preponderance of inches throughout. The notes along the right side of the builder show the results of my research for steps that are more comfortable for people to use.

All the values can be tweaked and, when ready, the Generate button can be clicked to create the stairs. In retrospect, I should have made the data entry fields sliders that would allow for immediately seeing the results of changing a value and to prevent bad values being entered. However, at the time of development I was more concerned with getting to the end result of having a 3D staircase model than making a fully featured and streamlined application. Room for improvement in the future, perhaps.

[Stairs from the stair builder.]
Stairs from the stair builder.

It took a few hours to create my little stair builder program. I probably could have modelled the final stairs without the program in about the same time or less BUT first, making this program was a fun little challenge, and second, now that I have this program I can make more staircases in a matter of seconds. So a few hours now to save many more hours in the future seems like a sound investment to me.