Difference between revisions of "Game:Jump Wheel"

From Hackerspace ACKspace
Jump to: navigation, search
m (File to Media link (cleans text))
m (whoops, another typo (hasty speed is rarely good))
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Project
 
{{Project
|State=Active
+
|Featured=No
|Members=Lots of participants
+
|State=Completed
 +
|Members=Multiple
 
|Description=Synchronize your jump with your coop players and beat the record
 
|Description=Synchronize your jump with your coop players and beat the record
 +
|GitHub=JumpWheel
 +
|Picture=JumpWheel.png
 
}}
 
}}
[[File:JumpWheel.png|335px|thumb|right|Our publicity stunt project]]
+
Note that there is another GitHub repository game that works with the jump pads: [[GitHub::https://github.com/ACKspace/MineCart|MineCart]]
  
 
== synopsis ==
 
== synopsis ==
Line 13: Line 16:
  
 
Lots of participants worked or helped on this; add your name if you were involved.
 
Lots of participants worked or helped on this; add your name if you were involved.
 +
 +
== the game ==
 +
You are standing on a plate on a big wheel.  If you jump, you will cause an imbalance to the wheel and it will start to roll.  The trick is to jump sequentially and have the wheel roll as fast as possible to the finish line.
 +
Some keys:
 +
* {{k|1}}...{{k|4}} player 1 to 4 jump
 +
* {{k|5}} reset the game (reload the page), depending on the number of players on the wheel
 +
* {{k|ctrl}} + {{k|space}}: edit group name
 +
* {{k|ctrl}} + {{k|1}}...{{k|4}}: edit player name
 +
* {{k|←}} or {{k|→}}: roll wheel (cheat)
 +
* {{k|shift}} + {{k|←}} or {{k|→}}: roll wheel fast (cheat)
 +
* {{k|alt}} + horizontal mouse move: set wheel location (cheat)
 +
* bottom right click: reset players
 +
* {{k|ctrl}} + {{k|shift}} + bottom right click: reset game and highscores
  
 
== the software ==
 
== the software ==
Line 19: Line 35:
 
When the wheel crosses the finish, the score is calculated from the time it took to finish.
 
When the wheel crosses the finish, the score is calculated from the time it took to finish.
  
You can fetch the [[Media:Jump_Wheel.tar|game files here]], extract anywhere but the steam folder and run game.html in chrome or firefox.
+
You can fetch the game files from github, extract anywhere but the steam folder and run game.html in chrome or firefox.
  
 
== the hardware ==
 
== the hardware ==
The human interface part consists of a mechanical part: the jump pads, and an electrical part: the arduino uno.
+
The human interface part consists of a mechanical part: the jump pads, and an electrical part: the Arduino Leonardo.
 
For the jump pad, you'll need some
 
For the jump pad, you'll need some
 
* strips/slats of wood
 
* strips/slats of wood
Line 29: Line 45:
 
* some wire to solder on to it  
 
* some wire to solder on to it  
  
For creating the link from jump pad to computer, an arduino uno is programmed as a keyboard interface
+
== the firmware ==
 +
For creating the link from jump pad to computer, an Arduino Leonardo is used as a keyboard interface.
 
This allows one to send up to 6 keystrokes at a time (as part of the USB HID class payload)
 
This allows one to send up to 6 keystrokes at a time (as part of the USB HID class payload)
 
+
The Arduino sketch can be found [[GitHub::https://github.com/ACKspace/jumppad|here]]
 
 
== the firmware ==
 
There are actually two parts of firmware
 
 
 
The first part reads some inputs set as pullup.
 
If the contact breaks from ground, the corresponding key down is sent, followed by a key up after 500ms.
 
Here is the snippet:
 
  // set pin numbers (cheesy, yes, at some point this will change in a for loop, or something similar):
 
  const int btnPlate[ 4 ] = { 9, 10, 11, 12 };
 
  boolean btnState[ 4 ]  = { true, true, true, true };
 
  long btnTime[ 4 ] = { 0, 0, 0, 0 };
 
 
 
  // Arduino USB Keyboard HID
 
  uint8_t keybuf[8] = { 0 };
 
 
 
  void setup( )
 
  {
 
   
 
    pinMode(btnPlate[ 0 ], INPUT_PULLUP );
 
    pinMode(btnPlate[ 1 ], INPUT_PULLUP );
 
    pinMode(btnPlate[ 2 ], INPUT_PULLUP );
 
    pinMode(btnPlate[ 3 ], INPUT_PULLUP );
 
 
 
    Serial.begin( 9600 );
 
  }
 
 
 
  void loop( )
 
  {
 
    handleButton( 0 );
 
    handleButton( 1 );
 
    handleButton( 2 );
 
    handleButton( 3 );
 
  }
 
 
 
  void handleButton( int _button )
 
  {
 
    if ( digitalRead( btnPlate[ _button ] ) != btnState[ _button ] )
 
    {
 
      btnState[ _button ] = digitalRead( btnPlate[ _button ] );
 
      if ( btnState[ _button ] && !btnTime[ _button ] )
 
      {
 
        // Send keypress, start at index 2, and write keyboard keys '1' and beyond
 
        keybuf[ 2 + _button ] = 0x1e + _button;
 
        Serial.write( keybuf, 8 );
 
 
 
        btnTime[ _button ] = millis();
 
      }
 
    }
 
 
 
    if ( btnTime[ _button ] && ( btnTime[ _button ] + 500 < millis() ) )
 
    {
 
      keybuf[ 2 + _button ] = 0x00;
 
      btnTime[ _button ] = 0;
 
      Serial.write( keybuf, 8 );
 
    }
 
  }
 
 
 
  void releaseKey()
 
  {
 
      keybuf[0] = 0;
 
      keybuf[2] = 0;
 
      Serial.write( keybuf, 8 );
 
  }
 
 
 
The second part is updating the controller AVR: an Atmega16u2.
 
First, on needs to create the hex file.
 
* Download the files from [https://github.com/harlequin-tech/arduino-usb/tree/master/firmwares/arduino-keyboard harlequin-tech's arduino-usb github page] (either by downloading the firmwares as a zip, or git checkout
 
* verify the AVR controller chip; in our case our arduino uno has a ATMEGA16u2
 
* Open the makefile and make sure the MCU = set correct (in our case we had to change atmega8u2 into atmega16u2)
 
* `make`, and remember the name of the *.hex file
 
* You probably want to create an arduino-usbserial hex file for the reversing process as well or you won't be able to program the uno itself via usb
 
 
 
Next, you need to download it into the controller.
 
You can do this in two ways.
 
 
 
=== using Atmel's FLIP ===
 
NOTE: not verified; Prodigity was able to use this method on a windows machine.
 
 
 
To program with Atmel's FLexible In-system Programmer, you'll need java x86 runtimes (jre).
 
This part failed to run properly on xopr's machine.
 
 
 
Download [http://www.atmel.com/tools/flip.aspx FLIP on the atmel page]
 
Follow their instructions, and you'll be able to upload hex files if you reset the controller chip.
 
 
 
=== using an external programmer ===
 
We tested it with Da Syntax's AVRISP2, but we had to make sure which port it uses.
 
After enabling some logging in the arduino IDE, we figured out it was 'usb'.
 
 
 
sudo avrdude -cavrispv2 -pm16u2 -Pusb -Uflash:w:Arduino-keyboard.hex
 
 
 
This command means: program with the AVRISP2 controller, for a processor ATMEGA16U2 via port 'usb' and write the flash with the given hex file.
 
 
   
 
   
 
== todo ==
 
== todo ==
 
* solve contact bounce for pads pulled to ground
 
* solve contact bounce for pads pulled to ground
 
* add extra modes (inverse lines, wsad, arrows, function keys, shift keys)
 
* add extra modes (inverse lines, wsad, arrows, function keys, shift keys)
* use requestAnimationFrame in the game
+
* change setInterval to requestAnimationFrame in game.html
* use v-usb stack on a single AVR to get rid of the arduino (and make it more compact)
+
* put velcro to the sides so we can stick them together (and prevents them from sliding around a bit)
 +
* add hardware layout (it has preparations for leds and analog inputs)
 +
 
 +
== done ==
 
* use descent wiring/connectors on the jump pads (for example: stereo jack plugs, so we can add some leds to the pads)
 
* use descent wiring/connectors on the jump pads (for example: stereo jack plugs, so we can add some leds to the pads)
 +
 +
Location: you can play it on the [[Location::ACKade]] (on the desktop)

Latest revision as of 15:15, 26 July 2017

Project: Game:Jump Wheel
Featured: No
State Completed
Members Multiple
GitHub JumpWheel
Description Synchronize your jump with your coop players and beat the record
Picture
JumpWheel.png

Note that there is another GitHub repository game that works with the jump pads: MineCart

synopsis

The game consists of a wheel with four players on it. If a player jumps, the center point of gravity of the wheel changes, and the wheel will turn.

To get a player to jump, a person needs to jump on a special built jump pad.

Lots of participants worked or helped on this; add your name if you were involved.

the game

You are standing on a plate on a big wheel. If you jump, you will cause an imbalance to the wheel and it will start to roll. The trick is to jump sequentially and have the wheel roll as fast as possible to the finish line. Some keys:

  • 1...4 player 1 to 4 jump
  • 5 reset the game (reload the page), depending on the number of players on the wheel
  • ctrl + space: edit group name
  • ctrl + 1...4: edit player name
  • or : roll wheel (cheat)
  • shift + or : roll wheel fast (cheat)
  • alt + horizontal mouse move: set wheel location (cheat)
  • bottom right click: reset players
  • ctrl + shift + bottom right click: reset game and highscores

the software

The on-screen part of the game is written in Javascript using HTML5 and some images from various classic computer games. If a key is pressed, the corresponding player jumps and the wheel will turn. When the wheel crosses the finish, the score is calculated from the time it took to finish.

You can fetch the game files from github, extract anywhere but the steam folder and run game.html in chrome or firefox.

the hardware

The human interface part consists of a mechanical part: the jump pads, and an electrical part: the Arduino Leonardo. For the jump pad, you'll need some

  • strips/slats of wood
  • two squares of plywood
  • two sheets of conductive tape
  • some wire to solder on to it

the firmware

For creating the link from jump pad to computer, an Arduino Leonardo is used as a keyboard interface. This allows one to send up to 6 keystrokes at a time (as part of the USB HID class payload) The Arduino sketch can be found here

todo

  • solve contact bounce for pads pulled to ground
  • add extra modes (inverse lines, wsad, arrows, function keys, shift keys)
  • change setInterval to requestAnimationFrame in game.html
  • put velcro to the sides so we can stick them together (and prevents them from sliding around a bit)
  • add hardware layout (it has preparations for leds and analog inputs)

done

  • use descent wiring/connectors on the jump pads (for example: stereo jack plugs, so we can add some leds to the pads)

Location: you can play it on the ACKade (on the desktop)