18 April 2021

Dark Souls 3 Game Controller

 




  My game controller for Dark Souls 3 is designed to look and move like how it is represented in game. The shield is using the accelerometer for WASD movement, and the edge of the shield is wrapped in conductive material that when touched, the character will block. I use a sword modeled after a weapon in game called the Lothric Knight Sword, and use it as a stylus to tap and trigger a block when put against the shield, and an attack when pressed against the target dummy. The capacitive touch for the block and attack mappings was mostly to mimic how you hold your shield upwards to block, and when swinging the sword you actually attack. One thing to note is that in order to effectively move around without having mappings for camera movement, I needed the lock on button to target the enemy, I originally had it mapped to the sound sensor but I was unable to get it to function as I had wanted it to, so I only use a PS4 controller to enter the fog wall and adjust the camera at the beginning, but beyond that all the actions were using my game controller. The signifiers are related to the design, the shield controls blocking and the sword controls attacking so you can better understand what action does what. The movement of the shield from left to right and front to back is also a signifier of what movement will be presented in game. I was able to kill two bosses using the controller, and I was able to get a third boss less than half health but that boss in particular is difficult so I am happy with just getting that far. I wish I could have spent more time on the "target dummy" and make it look like one of the enemies in the game but I ran out of time. One problem I had with my original design was whether I should connect the sword to the shield or keep it free/wireless from everything else. I decided to leave the sword alone so that it would allow for more movement like swinging it around, and instead attached the target dummy to the shield to be the trigger for the attack. My question is: do you think I made the right decision with this?



#include <Keyboard.h>

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

const int debounce = 100;
const int threshold = 1000;


void setup() {
  // put your setup code here, to run once:
  CircuitPlayground.begin();
  //create pin for switch to turn on and off
  pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);
  //create pin for attack
  //create pin for sound lock on
  Keyboard.begin();
  Serial.begin(9600);
 

}

void loop() {
  // put your main code here, to run repeatedly:
  //accelerometer setup
  float x = CircuitPlayground.motionX();
  float y = CircuitPlayground.motionY();
  float z = CircuitPlayground.motionZ();
  //if slideswitch is on:
  if(digitalRead(CPLAY_SLIDESWITCHPIN)) {
    if(CircuitPlayground.readCap(A6) > threshold) {
      Keyboard.press('C');
      //delay(debounce);
      //if attack pin is above threshhold, press right mouse button
    }
    else if(CircuitPlayground.readCap(A6) < threshold) {
      Keyboard.release('C');
    }
    
    if(CircuitPlayground.readCap(A4) > threshold) {
      Keyboard.press('V');
      //delay(debounce);
    }
    else if(CircuitPlayground.readCap(A4) < threshold) {
      Keyboard.release('V');
    }

    
    if(z > 4) {
      Keyboard.press('W');
      //delay(debounce);
      //when z accelerometer is in range, press W
    }
    if(z < -4) {
      Keyboard.press('S');
      //delay(debounce);
      //when z accelerometer is in range, press S
    }
    else if(z < 4 && z > -4) {
      Keyboard.release('W');
      Keyboard.release('S');
    }
    if(x < -4) {
      Keyboard.press('A');
      //delay(debounce);
      //when x accelerometer is in range,press A
    }
    if(x > 4){
      Keyboard.press('D');
      //delay(debounce);
      //when x accelerometer is in range, press D
    }
    else if(x < 4 && x > -4) {
      Keyboard.release('A');
      Keyboard.release('D');
    }
  }
  
  //Serial.println(CircuitPlayground.readCap(A4));
  //Serial.println(CircuitPlayground.readCap(A6));
  //Serial.println(x);
  //Serial.print("\t");
  //Serial.println(y);
  //Serial.print("\t");
  //Serial.println(z);
  //Serial.print("\t");
  //Serial.println(CircuitPlayground.soundSensor());
}




No comments:

Post a Comment

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