Building Snake In TouchDesigner – Step Two


Building Snake In TouchDesigner – Step Two

I’ve made lots of progress since my last post. It’s now a reasonably-playable snake game with a title/death screen, food, growth, wall collision, self collision and points tracking.


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.

You can download the updated version here: MMMFlatSnake_v2.toe

Post your comment