Motion Controlled Space Invaders Using webrtc and canvas
Join the DZone community and get the full member experience.Join For Free
tl;dr: play the game here (requires current chrome, opera of firefox with webrtc enabled): motion controlled space invaders
a couple of days ago i ran across an article on reactive super speed electromagnet dot display . for the promotion of a new crime show they created an interactive board that responded to the audience in front. the follow image better explains what i'm getting at:
i really like way it looks, the old bit style graphics combined with motion detection looks really nice. so i tried to recreate this in html5 using canvas for rendering and webrtc to control the camera input (you need a recent version of chrome, opera of nightly firefox). since just moving your arms around and seeing it on the screen is nice for the first couple of minutes, it quickly gets boring, so i added a game element using the 8-bit class space-invaders ( play the game here ):
the goal of this game is to try and hit the red "invader", without hitting the white ones. you get a point for every red one you hit. once you hit it, another one will light up for you to hit. the game is controlled by you moving in front of the webcam. if you want to get the maximum score you'll have to move slowly or use your hands. you can also of course just headbang ferociously. won't get you much points however :)
in future articles i'll dive a bit into the techniques used for this (very small) game:
you can play this game at: http://www.smartjava.org/examples/spaceinvaders/
Published at DZone with permission of Jos Dirksen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.