I finally got my Oculus Rift! As a first test, I want to build a 3D Spherical Snake game. As I’ve been learning TouchDesigner and positing its usefulness as a prototyping tool, I aim to build out the game first in TD, testing the mechanics, graphics and gameplay before I set about coding it in C++.
First thing I’ve set out to do is build a normal 2D Snake game in Touch Designer before I start getting all tricky with the 3D sphere stuff. I took a few hours yesterday, and I’ve now got a controllable 3D snake moving on two axes, with variable speed and proper growth, controllable via a single number in a DAT.
It’s a reasonably simple setup, but shows some tricks that I’ve learned that may be helpful for beginners. For example:
Using a Fan CHOP to figure out which keyboard button was pressed from a series of options (like up, down, left, right)[/]
Using a Sweep CHOP to draw a 3D object[/]
Using mod to call methods contained in DATs[/]
Using a startup script (‘execute1′ in this setup)[/]
I may tackle the 3D movement next, though there are still many game items left to be implemented: Food Placement, Food Consumption, Self-Collision, Wall-Collision and Death.
Note: also posted on my blog. I’ll post future updates in both locations.
The logic is mostly done in Python, with Touch Designer providing the 3D engine and visual problem-solving environment.
I’m trying out using a single DAT to track all global variables (called ‘define’ in this project, though that winds up looking funny in the Python). I know I can store globals behind the scenes, but for prototyping like this I enjoy being able to see them all while I’m building and debugging. A table DAT is an easy object to read to and write from without the issues you can get when trying to export your values to different operators.
To define the game board, I’m using a Grid SOP to create a Table of point positions. By placing a cube at each point, I can see my playing field.
I can also use this list of points to figure out if my snake is touching one of the edges, and to choose a spot to place food. One of the cool things about generating the playing field this way is that I can use deformers in Touch Designer to warp the points on the field and all of my logic should still work the same!
There’s a few bugs that are popping up - I’m not sure if it’s on my side or TouchDesigner, so I’ll report on those once I have a clear idea of what’s happening.
Also definitely agree about using Table DATs. I can’t imagine what I’d do if someone sent me a project where there were a ton of variables defined behind the scenes. Would make it impossible to decipher.
They work great if you setup a little component at the top of your network with a bunch of Table DATs, set a global variable to the path of that component, like var(‘BRAINS’) and then you can call that component pretty quickly from anywhere in your project when you need to report back to the mothership DATs or call/write some information.
awesome , am planning to dig into Kinect & the the game Pong … nice material to learn myself the basics in Python and game structure. Hooked up the Kinect yesterday and looked up the channels, looks pretty cool. Some work to do this weekend