26 November 2023

Dig Dug Pump Controller

 

By: Joshua Martin

Description:

For my project, I have constructed a game controller fitting for the game: Dig Dug. The design of the controller is modeled to a close representation of the pump that the character uses in game when defeating enemies, which the idea of it is to bring in another level of immersion to the gaming experience. The handles on the side of the controller act as movement. One only either side of the handle is interacted, being pulling it up or down, the character will move left or right depending on which side you pull. If both handles are pulled either down or up, then the character will move down or up respectively. The main pump at the top acts as the main action for the character, meaning that when you start pumping the controller, then the character will also start pumping in game. The pump is the main selling point to the immersion as it is the whole premise to the game. The task in the game is to pump enemies, so pumping with the controller is designed to make it feel like you are pumping them in game. The main draw to this controller is the design and functionality to it, which means that this controller would feel more at home in an Arcade Cabinet. With a design like this, seeing a Cabinet with this kind of controller on it for Dig Dug would sure attract some attention from users. But the main question is, would this kind of controller spark your interest if you were to see this at an Arcade?

Schematic:


The Code:


#include <Keyboard.h>
#include <KeyboardLayout.h>

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

int leftUpPin = 1;  //A7
int leftDownPin = 0; //A6
int leftUpRead;
int leftDownRead;

int rightUpPin = 12; //A0
int rightDownPin = 9; //A2
int rightUpRead;
int rightDownRead;

int pumpPin = 3; //A4
int pumpRead;

bool flag = true;

void setup() {
  // put your setup code here, to run once:
  CircuitPlayground.begin();
  Keyboard.begin();
  Serial.begin(9600);
  delay(1000);
  pinMode(leftUpPin, INPUT_PULLUP);
  pinMode(leftDownPin, INPUT_PULLUP);
  pinMode(rightUpPin, INPUT_PULLUP);
  pinMode(rightDownPin, INPUT_PULLUP);
  pinMode(pumpPin, INPUT_PULLUP);


// set pinmode all arrow keys leftUp,down, etc.. (INPUT_PULLUP)

}

void loop() {

 // if the right switch gets flipped up or down, then hold "Right Arrow Key"
rightUpRead = digitalRead(rightUpPin);
rightDownRead = digitalRead(rightDownPin);
leftUpRead = digitalRead(leftUpPin);
leftDownRead = digitalRead(leftDownPin);
 if(rightUpRead == LOW && leftUpRead != LOW && leftDownRead != LOW || rightDownRead == LOW && leftUpRead != LOW && leftDownRead != LOW) {
   Keyboard.press(KEY_RIGHT_ARROW); //Call for keyboard release Keyboard.release(KEY...)
   delay(10);
    Keyboard.release(KEY_RIGHT_ARROW);
 }

  // if the left switch gets flipped up or down, then hold "Left Arrow Key"
leftUpRead = digitalRead(leftUpPin);
leftDownRead = digitalRead(leftDownPin);
rightUpRead = digitalRead(rightUpPin);
rightDownRead = digitalRead(rightDownPin);
 if(leftUpRead == LOW && rightUpRead != LOW && rightDownRead != LOW || leftDownRead == LOW && rightUpRead != LOW && rightDownRead != LOW) {
   Keyboard.press(KEY_LEFT_ARROW); //Call for keyboard release Keyboard.release(KEY...)
   delay(10);
    Keyboard.release(KEY_LEFT_ARROW);
 }

  // If both Switches are flicked up, then hold "Down Arrow Key"
  rightUpRead = digitalRead(rightUpPin);
  leftUpRead = digitalRead(leftUpPin);
 if(leftUpRead == LOW && rightUpRead == LOW) {
   Keyboard.press(KEY_DOWN_ARROW);
   delay(10);
  Keyboard.release(KEY_DOWN_ARROW);
  }

  // If both Switches are flicked down, then hold "Up Arrow Key"
  rightDownRead = digitalRead(rightDownPin);
  leftDownRead = digitalRead(leftDownPin);
 if(leftDownRead == LOW && rightDownRead == LOW) {
   Keyboard.press(KEY_UP_ARROW);
   delay(10);
 Keyboard.release(KEY_UP_ARROW);
  }
  // If the pump completes the Aluminum circuit, then press the "Space" bar
  // True statement for a pumpPin
  pumpRead = digitalRead(pumpPin);
 if(pumpRead == LOW && flag == true) {
  Keyboard.write(' ');
  flag = false;
  }
  if(pumpRead == HIGH && flag == false) {
    flag = true;
  }

 Serial.print(rightUpRead);
 Serial.print("\t");
 Serial.print(leftUpRead);
 Serial.print("\t");
 Serial.print(rightDownRead);
 Serial.print("\t");
 Serial.println(leftDownRead);


}

Video Demonstration: 

https://youtu.be/WyfGVES9Dlc




No comments:

Post a Comment

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