I want to show you how easy it is now-a-days to make your own game that can be controlled by moving your body. You will need just a laptop with a webcam and some programming skill.
If you don't have a laptop and webcam, or if you don't know how to program, you can still read this tutorial for entertainment and then you can play my game, because I'm adding it to this article.
Step 1: Language and Motion Detection LibraryThere is no need to reinvent the wheel. On the internet there are many libraries which handle motion detection and they are made for almost any language and free to use.
I decided to use Java because I wanted my game to be platform independent. It can be run on Windows, Mac, Linux.
I selected the OpenIMAJ library which allows not only motion detection but also makes it very easy to display and process graphics. You can see the picture attached to this step, that only using a few lines of code I'm able to make a motion detection application.
If you know Java and want to try, here is the really fast/simple tutorial on how to detect motion and handle graphics in OpenIMAJ.
I decided to make an Arkanoid game as my proof of concept, because it is really simple to implement.
Step 2: Short Tutorial to See How Easy It Is to Detect FacesI decided to show you how easy it is to detect faces in Java&OpenIMAJ. If you don't know programming, just skip this step ;-)
Here you have the code:
//first initialize the screen if HDVideoCapture vc = new VideoCapture( 1240,720 );//initialization of face detectorFaceDetector fd = new HaarCascadeDetector(40);//this creeates the window showing the captured webcam videoVideoDisplay vd = VideoDisplay.createVideoDisplay( vc ); vd.addVideoListener( new VideoDisplayListener() { public void beforeUpdate( MBFImage frame ) { //this does the face detection and display the frame around the face on screen List faces = fd.detectFaces( Transforms.calculateIntensity(frame)); for( DetectedFace face : faces ) { frame.drawShape(face.getBounds(), RGBColour.RED);
}
}
public void afterUpdate( VideoDisplay display ) { } });
Step 3: Making the SoundsJust for additional fun I made some sounds which make the whole game more playable. Together with my son (it was a fun for him) we made some stupid noises like hitting the rotten banana to fridge doors. Later I post-process the sounds in audacity and reuse them in a game.
Step 4: Play & FunIf you are interested in the full code, it is available here on gitlab. You are free to play with it.
If you are not interested in the code and you just want to try the game, I'm attaching it in this step.
The game is written in Java. You can run it in your console using this command:
java -jar ./target/realkanoid-1.0-SNAPSHOT-jar-with-dependencies.jar
Or you can just click on the file and probably your Windows/Mac/Linux system will manage to run it without any problems.
If you decided to try my game, please write in the comment your feelings on it. I'm curious if you all find it playable.
Comments
Please log in or sign up to comment.