17 April 2021

FnF Game Controller

 



                The conceptual model behind this design is shaky at best. The speaker container itself does not afford much in term of tilting, rather sitting it down and listening. However this speaker contains several UI elements, arrows of the games corresponding colors are on the outside of the speaker to coney to the user the intended use. The Design also lights up to the corresponding color when tilted in the corresponding direction, to further strengthen the model and the feedback behind tilting the case to activate an arrow key. The inputs here are the titling of the model, and the outputs is an WASD input on the keyboard, along with the CPE lighting up to the corresponding color and direction of the corresponding arrow in FnF. The signifiers here are the arrows on the model and the “Tilt me” sign on the sides of the model that beckons the user to tilt the model. The feedback is the neopixels on the CPE lighting up in correspondence to the direction titled. Thus, this design affords being tilted in a direction to input a WASD key on the keyboard.

                This game is a Dance Dance Revolution style rhythm game with heavy themes around singing, dancing, and all the equipment needed to do these things in a professional fashion, which includes speakers. The use of a speaker as the contain is for several reasons: they are very easy and straightforward to turn in a way that works with the CPE’s accelerators, and though I could have used the microphone as the container, which would potentially build a better conceptual model with the game due to the gestures performed with the microphone in it, this would have been far more difficult to control from a gameplay perspective, which I consider to be a priority in the design.

 

How could I have improved this design?


//speaker custome controller for FNF
// By Tennyson Branch
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include <Keyboard.h>
//controller works by tilting CPR in a direction, and the keyboard reads

//that direction as a arrow input
const int debounce = 200;
//miliseconds before next key press

void setup() {
  // put your setup code here, to run once:

  CircuitPlayground.begin();

  Keyboard.begin();
  Serial.begin(9600);
  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
  float x = CircuitPlayground.motionX(); //initlaize acceleromter
  float y = CircuitPlayground.motionY();
  int r = map(x, -10, 10, 0, 255); //map accelerometer to use the values
  int b = map(y, -10, 10, 0, 255);
  Serial.print(x);
  Serial.print("x");
  Serial.print("\t");
  Serial.println(y);
  Serial.print(r);//right is 12 left is 240
  Serial.print("\t");
  Serial.println(b); //forward is 12 backwards is 240
  //serial monitor output to identify values
  CircuitPlayground.setPixelColor(0, 0, 150, 0);
  CircuitPlayground.setPixelColor(9, 0, 150, 0);
  CircuitPlayground.setPixelColor(1, 100, 0, 100);
  CircuitPlayground.setPixelColor(2, 100, 0, 100);
  CircuitPlayground.setPixelColor(3, 100, 0, 100);
  CircuitPlayground.setPixelColor(4, 0, 0, 100);
  CircuitPlayground.setPixelColor(5, 0, 0, 100);
  CircuitPlayground.setPixelColor(6, 100, 0, 0);
  CircuitPlayground.setPixelColor(7, 100, 0, 0);
  CircuitPlayground.setPixelColor(8, 100, 0, 0);
  //set pixel colors to arrow colors
  if (r <= 75) {
    Keyboard.press('d');
    delay(debounce);
    Keyboard.release('d');
    //if CPE is tilted right, presses and releases D key
  }
  if (r >= 195) {
    Keyboard.press('a');
    delay(debounce);
    Keyboard.release('a');
    //if CPE is tilted left, presses and releases A key
  }
  if (b <= 75) {
    Keyboard.press('w');
    delay(debounce);
    Keyboard.release('w');
    //if CPE is tilted forward, presses and releases W key

  }
  if (b >= 195) {
    Keyboard.press('s');
    delay(debounce);
    Keyboard.release('s');
    //if CPE is tilted back, presses and releases S

  }

}




No comments:

Post a Comment

Note: Only a member of this blog may post a comment.