Shape Game C# Sample

Kinect for Windows 1.5, 1.6, 1.7, 1.8


When you run this sample, you see the following:

  • The tracked skeleton of the players and shapes (circles, triangles, stars, and so on) falling from the sky.
  • Players can move their arms and legs to bump into shapes, make them change direction, or even explode.
  • Players can say commands, such as "make bigger" or "make smaller", to increase or decrease the size of the shapes. Players can say other commands, such as "show yellow stars", to change the color and type of the falling shapes.
The Sample Uses the Following APIsTo Do This
ColorImageFormat.RgbResolution640x480Fps30 enumeration valueChoose the color stream format including the data type, resolution, and frame rate of the data.
ColorImageStream.Enable MethodStart streaming color data.
TransformSmoothParameters StructureSet default values for smoothing skeleton joint data.
SkeletonStream.Enable MethodStart streaming skeleton data.
KinectSensor.SkeletonFrameReady EventAdd an event handler for the skeleton data. The sensor will signal the event handler when each new frame of skeleton data is ready.
SpeechRecognizer class Create a speech recognizer. Implement the grammar (words that the application will recognize) in the recognizer.
RecognizerSaidSomething event handlerAdd an event handler to respond to something the user says.
KinectAudioSource.AutomaticGainControlEnabled Property, KinectAudioSource.BeamAngleMode Property, and KinectAudioSource.Start MethodInitialize the audio properties of the sensor in the SpeechRecognizer class in SpeechRecognizer.cs.
SetInputToAudioStream and RecognizeAsyncSet the audio input stream to the recognizer, and start the audio in the SpeechRecognizer class in SpeechRecognizer.cs.
KinectSensor.Start Method and KinectSensor.Stop MethodStart or stop the sensor.
KinectSensor.SkeletonFrameReady EventAdd an event handler for the skeleton data. The sensor will signal the event handler when each new frame of skeleton data is ready.
SkeletonFrameReadyEventArgs.OpenSkeletonFrame MethodGet a frame of skeleton data in the event handler.
Skeleton classCreate an array of skeletons to store skeleton data locally.
SkeletonFrame.CopySkeletonDataTo MethodCopy a frame of skeleton data to a pre-allocated array.
Methods in HandleGameTimer in MainWindow.Xaml.csAdvance the animations and perform hit testing of falling geometry with a tracked skeleton.
Methods in RecognizerSaidSomething in MainWindow.Xaml.csRespond to speech events.

Speech Vocabulary

Here is a list of the entire vocabulary implemented in the sample:

To do this:Say any of these:
Reset everything to initial settings"reset", "clear"
Pause the falling shapes"stop", "freeze", "pause game"
Resume game"go", "unfreeze", "resume", "continue", "play"
Fall faster"speed up", "faster"
Fall more slowly"slow down", "slower"
Drop more shapes"more", "more shapes"
Drop fewer shapes"less", "fewer"
Show bigger shapes"larger", "bigger", "bigger shapes"
Show largest shapes"huge", "giant", "super big", "biggest"
Show smaller shapes"smaller"
Show smallest shapes"smallest", "tiny", "super small"

Any combination of color and shape may be spoken as well:

  • Colors: "red", "orange", "yellow", "green", "blue", "purple", "violet", "pink", "brown", "gray", "black", "white", "bright", "dark", "every color", "all colors", "random colors"
  • Shapes: "triangles", "squares", "stars", "pentagons", "hexagons", "circles", "seven-pointed stars", "all shapes", "everything", "bubbles", "shapes"

Note: Most phrases can be preceded by any words. For example: "Now do green circles" will drop green circles. "Please go faster" and "even faster" will indeed speed things up.

To run a sample you must have the Kinect for Windows SDK installed. To compile a sample, you must have the developer toolkit installed. The latest SDK and developer toolkit are available on the developer download page. If you need help installing the toolkit, look on this page: To Install the SDK and Toolkit. The toolkit includes a sample browser, which you can use to launch a sample or download it to your machine. To open the sample browser, click Start > All Programs > Kinect for Windows SDK [version number] > Developer Toolkit Browser.

If you need help loading a sample in Visual Studio or using Visual Studio to compile, run, or debug, see Opening, Building, and Running Samples in Visual Studio.

Community Additions