Jos works as Architect for JPoint. In the last couple of years Jos has worked on large projects in the public and private sector. Ranging from very technology focusses integration projects to SOA/BPM projects using WS-* and REST based architectures. Jos has given many presentations on conferences such as Javaone, NL-JUG, Devoxx etc., and has written two books for Manning: Open Source ESBs in Action and (published in the next couple of months) SOA Governance in Action. In this last book Jos shows how, with some good practical governance approaches, you can create great WS-* and REST based services and APIs. Besides this he has his own blog where he writes about interesting technologies and shares his ideas about REST, API Design, Scala, Play and more. Jos is a DZone MVB and is not an employee of DZone and has posted 49 posts at DZone. You can read more from them at their website. View Full User Profile

Motion Controlled Space Invaders Using webrtc and canvas

08.07.2012
| 584 views |
  • submit to reddit

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:

Motion detection

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):

swat1.jpg

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, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)