26 November 2023

Final controller: Packman Championship Edition


Design: 

    The controller that I created is a alternative method controller for the game Pacman championship edition that is comprised of three major parts. The base is 3d printed cuboid with a circular cavity. In this cavity is a glued down holder for the circuit playground. The second main component is a 3d printed bowl with four circular cavities which in turn have small holes through them. On the edges of each circular cavity are two strips of copper tape with wires attached to the bottom. One of these wires leads to the 3.3 volt output of the circuit playground, and the other one leads to one of four inputs on the circuit playground: A1, A2, A5, and A6. The final main component is a conductive metal ball. When the ball falls into one of the four holes it bridges the gap between the copper strips and outputs one of four repeated keystrokes, w, a, s or d, for as long as the ball is in the hole. The idea of the controller being that since Pacman is round the input for controlling him should also be round. The ball itself represents packman and tilting the bowl moves packman In the same direction as the bowl is tilted creating a direct connection between the action on screen and the action of the player. The controller provides feedback through the action happening in game but also through the ball setting into a hole insuring the player the input is being received and also what input is being received. The controller affords only the movement of a ball and the four keyboard inputs. My question is: How could I have made the controller feel more responsive?

Code:

//Gets keyboard libraries
#include <Keyboard.h>
#include <KeyboardLayout.h>
//Gets Circuit playground libraries
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_CircuitPlayground.h>
void setup() {
  //Starts the circuit playground and keyboard
  CircuitPlayground.begin();
  Keyboard.begin();
  //Activates and sets the four pads used
  pinMode(A1, INPUT_PULLDOWN);
  pinMode(A2, INPUT_PULLDOWN);
  pinMode(A5, INPUT_PULLDOWN);
  pinMode(A6, INPUT_PULLDOWN);
}
void loop() {
  //Each if statement checks if it has recived a voltage input then presses the corresponding key
    if(digitalRead(A1))
    {
      Keyboard.press('W');
    }
    else if(digitalRead(A2))
    {
      Keyboard.press('A');
    }    
    else if(digitalRead(A5))
    {
      Keyboard.press('S');
    }
    else if(digitalRead(A6))
    {
      Keyboard.press('D');
    }  
    else
    {
      //Delays the code by 50 milliseconds then un presses any keys still pressed
      delay(50);
      Keyboard.releaseAll();
    }
}


 



No comments:

Post a Comment

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