"Celerity: Sensory Overload" - The game, the story, the code...
Today's project by Adam David Hill is one that shows off just what you can do if you have extra sensors in your Windows 8 laptop/notebook/ultrabook...
It also gives you a number of tips on how to setup an XNA dev environment on Windows 8 and best of all is a "inside baseball" kind of post, talking about the design and implementation and lessons learned,
This article will walk you through the process of designing and creating a game like Celerity: Sensory Overload, using XNA 4 in Visual Studio 2012 for a Windows 8 Ultrabook™ and publishing it in the Intel AppUp store
This article is an entry in the runners up Ultrabook™ Article Competition. As per the rules it borrows heavily from the original game article, but focuses on teaching you how we made it and dives deeper into the code.
This article is divided into the overall tasks which went into making the game, followed by a reflection on the competition experience and other notes.
- Initial Ideas
- Get XNA working on Win 8 (which turned out to be a nightmare!)
- Produce music & sound effects
- Design UI
- Draw UI
- Structuring the application code
- Code UI
- Code tunnel
- Code tunnel & obstacle shader
- Code collision detection
- Code audio
- Code game logic
- Code input (including sensors and how to fix XNA's broken touch ability)
- Code head tracking
- Create an installer
- Publish via Intel AppUp
- Reflections, Conclusions and Closing Remarks
Reading the competition brief carefully, there was a clear emphasis on both showing off hardware sensor capabilities and coming up with something innovative. This led to two key themes with the game being sensor controls and an innovative re-take on IR Head Tracking which can be achieved with only a basic webcam through face detection.
The inclinometer naturally lends itself to tilt-based steering, so the first idea was free flight steering. Having tried a few tunnel games, some of them do use this, but I found the games tended to simply be more playable when the controls were based on a more simple rotation of the tunnel, so the control was constrained to only tilting left and right, with the forward direction automatically remaining aligned with the tunnel.
At this stage the brief was "build some sort of tunnel game which works on the Ultrabook™, uses sensors for steering and achieves the head tracking effect with only a webcam input". From there we specified a minimum viable product.
I cannot stress enough how much defining the minimum viable product helped in this competition. Time was so tight and the potential for endlessly adding small additional features which might break the deadline was significant. As it turned out the game was shipped with one single feature added beyond the bare minimum (the inclusion of sensor-fired smart bombs).
The minimum viable product was defined in abstract terms as being:
- Something which constitutes a game (to fit the competition category)
- Something which makes natural and logical use of Ultrabook™ sensors
- Something which includes our innovative camera-based head tracking idea
And specifically having the following features:
- Product shall feature moving through a textured 3D tunnel
- Product shall feature sensor-based steering via tunnel rotation
- Product shall feature head-tracking-informed view matrix adjustment
- Product shall feature a 3D avatar (ship) and 3D collidable hazards
- Product shall feature sounds and music
- Product shall feature touch-enabled, responsive UI
- Product shall feature a timer (so the player can attempt to improve on previous attempts)
- Product shall meet Intel AppUp criteria
As I was familiar with XNA and C# I wanted to use them to build the game, however there are a number of obstacles in having them work smoothly on Windows 8. There were some immediate obstacles which had to be overcome to make the project viable:
- Visual Studio 2012 does not support XNA projects
- XNA Game Studio 4 doesn't (seem to) install on Windows 8
- XNA Touch is deliberately disabled for Windows (eek!)
- Windows 8 libraries (for the sensors) can't be accessed in my then-current Windows 7 development environment
I believe this was the first code-related contest I've entered. It was a tiring, exciting, nail-biting, challenging and surprisingly social experience. The amount of threads on the competition page and comments in people's articles are testament to the fantastic amount of support and constructive criticism the community gave itself.
In a conversation with one of my colleagues a few days before the deadline he asked if we were going to make it on time and I honestly had no idea. We'd made so much progress and the rate at which features were completed and issues were being resolved we were right on the border line. I knew of 6 distinct and unrelated major issues still outstanding (writing an installer for the first time, signing an app for the first time, getting touch working in XNA, unimplemented collision detection, getting the sensors working and a worrying tendency to just show a black screen). At that frenzied stage, however, a strange sense of peace came over me, as I knew regardless of winning or even being accepted in time, we had pushed ourselves further than we realised we were able.
We had done ourselves proud.
My last piece of advice is regarding how we managed to get those last issues nailed in the closing hours of the project. Searching the net for solutions, a couple of them, in context were said to be impossible. How were they resolved?
Sheer, bloody-minded determination.
I taught myself a profound lesson in those days which does not appear to be mentioned in any of the software development texts I've encountered. I now earnestly believe that a trait of an effective programmer, which I briefly experienced for myself and now recognise in others, was that down-right refusal to give up on a problem has this funny habit of leading to a solution.
I'll close with a quote from Einstein, "It's not that I'm so smart, it's just that I stay with problems longer."
The source? Of course!
Celerity: Sensory Overload is a tunnel obstacle race game written in XNA for the Intel Ultrabook / Windows 8, featuring head tracking.
Celerity was a competition entry in the 2012 CodeProject App Innovation Contest where contestants sought to make innovative use of the Ultrabook hardware, particularly the sensors.
The program will work fine on any x86 installation of Windows 8 (i.e. desktop) and will make use of sensors and camera if they are available.
Now that you've had the story and the code, start playing! (No, not the game, with the code!
This conversation has been locked by the site admins. No new comments can be made.