The controller is a real sledgehammer; the same tool used in Getting Over It. The Circuit Playground Express sits inside the hammer head and uses its built-in accelerometer to track movement. The hammer is held horizontally in front of you with the head pointing away from your body and the flat face pointing down, essentially treating the air in front of you as a mousepad. Moving the hammer through the air translates directly into mouse movement on screen. Two buttons are mounted in the handle using a breadboard, each activated by a 3D printed plunger that pokes out of the handle. Holding the first button activates the Z axis on the accelerometer, so pushing the hammer away from you or pulling it toward you maps to the push and pull mechanics in the game. The second button recalibrates the hammer in game to the neutral position for ease of use. The controller fits with the difficult nature of the game, adding an additional challenge to the gameplay.
#include <Mouse.h>#include <Adafruit_CircuitPlayground.h>#include <Adafruit_Circuit_Playground.h>void setup() {// put your setup code here, to run once:// circuit playgrouund begin// Set neutral position x// Set neutral position y// Set deadzone// pinMode Zbutton 10 INPUT// pinMode resetButton 9 INPUT}void loop() {// put your main code here, to run repeatedly:// Read accelerometer x// Read accelerometer y// if hammer tilts left// move mouse left// if hammer tilts right// move mouse right// if hammer tilts up// move mouse up// if hammer tilts down// move mouse down// if hammer is near neutral// do not move mouse// if Z button pressed// Read accelerometer Z for push/pull// if reset button pressed// Set neutral position x// Set neutral position y}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.