Christmas is over and also New Year festivities, I also have some party with my renewal as MVP for the 7th time, so I’ll go back and start again with some posts about Kinect for Windows V2. For this post I’ll make a game “Rock Paper and scissors” with the new Kinect for Windows V2.
Note: if you don’t know how to play Rock, paper or scissors, Wikipedia explains it to you here .
The truth is that implementing this game is quite simple with Kinect for Windows V2, since now the HandState property supports several States
The first 3 allow us to have a match with the States of the game
- Open, paper
- Closed, rock
- Lasso, scissors
In this way, the only thing we have to do is to validate hand States with a Random computer-generated (by the way, the routine that generates the Random of an Enum have taken it from StackOverflow is a Marvel).
The main view of the app has a button that pressed down, start a timer with a downward counter for 5 seconds.Every tick of the timer displays the status of the hand of the player (line 24), and when the counter reaches zero, it generates a random game (line 41) value and validated the possibilities to define a winner (lines 48 to 80).
Note: The truth is that the validation of results section could implement it “in amore fashion way”, however it will be more complicated to put it on the post.
In the app I also display the video feed and the body position to display different colors for different hand states. Right now we have to make some adjustments using the new SDK to coordinate both feed like Zubair explains in his post.
The video below shows an example of the app running. In it you can see how the Random favors so that you always win Skynet and also as change the color of the hand in the positions of stone, paper, or scissors. .
When you return to Madrid, I shall speak with gem or Marta to help me with the aesthetic part and leave the app a bit more “pretty”. In addition to changing her way of start, to make it as the classic stone, paper scissors.
- Wikipedia, piedra, papel o tijera; http://es.wikipedia.org/wiki/Piedra,_papel_o_tijera
- Generate Random from Enum, http://stackoverflow.com/questions/319814/generate-random-enum-in-c-sharp-2-0
- Kinect For Windows V2 Deep Dive, http://www.zubairahmed.net/?p=1652
And as always, the disclaimer
“This is preliminary software and/or hardware and APIs are preliminary and subject to change“
Greetings @ Cordoba