18 April 2021

Pac-Man Game Controller

The project that I created is a game controller for one of the most well known games in the world, Pac-Man. As we all know Pac-Man is a classic among classics and it needs no introduction but just in case you somehow haven’t played Pac-Man, it is very simple. You simply use the directional arrow keys to direct the Pac-Man so that he can eat all the pellets in the level while avoiding the ghosts so you don’t lose a life. Unless of course, you happen to gobble up the big fruit which turns all the ghosts blue and allows the Pac-Man to eat them too, sending them back to their cage in the center to be redeployed and buying you some more time. For this project, I made a Pac-Man themed game pad that the player can use instead of those small pesky arrow keys. I figured it might be more fun and engaging for the player to tilt my game pad for movement than it would be to use the traditional method of movement. I also wanted to make my game pad intuitive so that any player could pick it up, take one look at it, and know exactly how to use it. I have drawn some arrows in each direction and a joystick in the center in order to convey to the player that they need to tilt the game pad in the direction they want to go just like they would with a joystick. I have also added some Pac-Man themed art to give the game pad that extra touch so that the player can feel like they are using something made especially for Pac-Man and nothing else. My one question for the audience would be which game do you think would have been better suited to this game controller, if any? Why?



    CODE

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

const int Time = 100;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  CircuitPlayground.begin();
  Keyboard.begin();
}

void loop() {
  // put your main code here, to run repeatedly:

  //data on xAxis
  float horizontal = CircuitPlayground.motionX();
  Serial.print(horizontal);
  Serial.print("\t");

  //Debugging tools for the Y Axis values
  float vertical = CircuitPlayground.motionY();
  Serial.print(vertical);
  Serial.print("\t");


  if (vertical >= 4) {
    Keyboard.write(217);
    delay(Time);
  }

   if (horizontal >= 4) {
    Keyboard.write(216);
    delay(Time);
  }

   if (vertical <= -4) {
    Keyboard.write(218);
    delay(Time);
  }

   if (horizontal <= -4) {
    Keyboard.write(215);
    delay(Time);
 }
}




VIDEO WAS TOO LARGE, HAD TO UPLOAD TO YOUTUBE.

LINK: https://youtu.be/VgmAdEhYlYc 



No comments:

Post a Comment

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