Shop OBEX P1 Docs P2 Docs Learn Events
Sensor Show "poor man's Wii" game demo — Parallax Forums

Sensor Show "poor man's Wii" game demo

AndreLAndreL Posts: 1,004
edited 2007-06-08 12:42 in Propeller 1
hop.gif·For the upcoming sensor show parallax asked me to put together a demo of something cool. So I took the gamepad, put a 2-axis acclerometer on it, interfaced it to one of the paddle games and presto you have a "poor man's Wii" controller. Attached is a pic.

Anyway, I thought that it was such a fun and easy project, everyone should upgrade their controllers with the memsic 2125, its non-invasive and gives you all kinds of cool play options. In this case, I made it so when you twist the paddle left and right or roll it around the +Z out of your body, it moves the paddle left and right. Its a lot of fun, was playing till 6:00am this morning.

Just a few lines of code to interface the driver that Beau wrote to any game.
    ' initialize m2125 (hold your breath, don't move)  
    acc.start(x_pin,y_pin)                              'start memsic 2125                                                      
    waitcnt(clkfreq/10 + cnt)                           'wait for things to settle 
    acc.setlevel                                        'assume at startup that the 2125 is level
 
    ... in the main line of game
 
    ' get accelerometer status
    raw := acc.ro                                       'Get raw value for acceleration
    mg := raw / clk_scale                               'convert raw acceleration value to mg's
    deg := acc.theta >> 19                              'scale 32-bit value to a 13-bit value
  
    dx := ((mg*SinCos(COS, deg)) ~> 18)
    dy := ((mg*SinCos(SIN, deg)) ~> 18)
 

    ' move player with accelerometer
    player_x += (dy ~> 6)


Of course, general filtering/smoothing would help a bit, and a derivative filter would·be nice so when you jerk the controller it can indicate a "throw ball". But, anyway, fun stuff. Let's see a whole slew of "gesture" games!·yeah.gif

Andre'
1200 x 800 - 213K

Comments

  • JT CookJT Cook Posts: 487
    edited 2007-06-07 01:15
    Ok, that is pretty cool. I could see a tennis game being feasable by swinging the controller like the racket or use two of them for a boxing game(actually you could pretty much rip off anything from Wii sports and make a smaller Hydra acclerometer version).

    Hmm, adding that to xracer would be a pretty sweet to give it analog control.

    Post Edited (JT Cook) : 6/7/2007 3:11:46 AM GMT
  • Dennis FerronDennis Ferron Posts: 480
    edited 2007-06-07 05:37
    Maybe you should sell an accelerometer-based controller as a Hydra accessory.
  • AndreLAndreL Posts: 1,004
    edited 2007-06-07 05:52
    Mabye a "cable" attachment might work that you can attach just like the one I did, this way you can re-use for other things. So it would come with the little m2125 or 3-axis on a pcb that you could velcro onto whatever and have pin headers for each signal, so you could attach them to male headers on the hydra card or somethnig else. That might be an idea in the future.

    Andre'
  • JT CookJT Cook Posts: 487
    edited 2007-06-07 06:00
    You could probably make a PS/2 hack for it then it can it plug into the mouse or keyboard port and not have to hack anything on the hydra (or even demo or proto board). I think that would be a pretty fun add on too, more so than the multiprop card.
  • LewisLewis Posts: 23
    edited 2007-06-07 15:10
    Wow this rocks... can't wait to try it. Someone can actually attach a couple of buttons to a board along with the accelerometer and make it into something someone can play using one hand... This way they'll have a "fire" button along with a "pause" or something...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Lewis [noparse][[/noparse]m80] -
  • Chris MerckChris Merck Posts: 55
    edited 2007-06-08 12:42
    Agreed JT. If the PS/2 interface was used either a mouse OR accelerometer-based control could be used for the same game (of course there is the question of speaking PS/2 protocol from the controller). The two-axis motion plus buttons interface of a mouse is very similar to the controller you describe.
Sign In or Register to comment.