18 April 2022

 Spray Paint Can Controller - Subway Surfers



    For my project, I wanted to create a compact, movement-based controller that both proved to be usable in real life, as well as possessing a strong conceptual tie to the game I chose. The game in question is Subway Surfers, a classic infinite run mobile run in which you play as a young street punk running through a trainyard with increasingly difficult obstacles appearing. One of the most obvious visual motifs is the very urban, graffiti-sprayed aesthetic that characterizes most of the game's visuals. In fact, with the character even holding a spray paint can on the start screen before you begin the game, I thought it was only natural to go with that as the base idea for my controller. 

    The controller features basic 1:1 mapping of the x and y axes of the Circuit Playground's built in accelerometer, as well as a shake function. In order to diminish the need for signifiers and keep the controller's function as intuitive as possible, the way in which you move the controller directly corresponds to the way in which your character moves. Tilt it to the right, your character moves right; Tilt the tip downward, and you duck/roll; etc. Overall, I feel this creates quite a strong conceptual model and connection between the game and the controller's function, as it allows you to better feel the momentum of the character, while also maintaining a visual link with the presentation of the game as well. Overall, I'm satisfied with my work, however easily one of the biggest flaws I had with this controller was dialing in its accuracy. Possibly due to how I mounted the Circuit Playground snap case, as well as placing the CPE at the bottom of the controller rather than the top, did seem to potentially affect the way in which the accelerometer processed movement. 

    With that in mind, and after watching the video, what are your thoughts on the accuracy of the controller? Do you feel like it could use fine tuning in that department? And, if so, how would one go about achieving that goal?


#include <Keyboard.h>


#include <Adafruit_CircuitPlayground.h>

#include <Adafruit_Circuit_Playground.h>


const int debounce = 400;//delay between key presses

int shakeThresh = 23;//amount required to activate shake command


void setup() {

  // put your setup code here, to run once:

//initializing processes and defining pins

Serial.begin(9600);

CircuitPlayground.begin();

Keyboard.begin();

pinMode(CPLAY_LEFTBUTTON, INPUT_PULLDOWN); 

pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);


}


void loop() {

  // put your main code here, to run repeatedly:

//Accelerometer x and y readings

float x = CircuitPlayground.motionX();

float y = CircuitPlayground.motionY();

//determining shake value by adding up the absolute value of all accelerometer axes

float shake = abs(CircuitPlayground.motionX())

  + abs(CircuitPlayground.motionY())

  + abs(CircuitPlayground.motionZ());

//Serial monitor shenanigans

Serial.println(x);

Serial.print("\t");

Serial.println(y);

//Gyro controls

if (x<=-5) {

  Keyboard.write(215); //Right arrow key

  delay(debounce);

}

if (x>=5) {

  Keyboard.write(216); //Left arrow key

  delay(debounce);

}

if (y>=5) {

  Keyboard.write(217); //Down arrow key

  delay(debounce);

}

if (y<=-4.5) {

  Keyboard.write(218); //Up arrow key

  delay(debounce);

}

if (shake > shakeThresh) {

  Keyboard.write(' '); //Spacebar

  delay(debounce);  

}

}


 






No comments:

Post a Comment

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