18 April 2021

Game Controller: Snake II





Video:



Description:

    My controller is inspired by the classic game, Snake II. This game was originally featured on the old Nokia cell phones and it since can be found on many emulators online. I wanted to make a controller for this game so that it can enhance the gaming experience when playing this classic game by putting an old Nokia phone in the hands of the player. I would have preferred to use a real Nokia phone but I was unable to find one during this time so I had to settle with creating a replica using a box and some crafting supplies. 

    My design is very simple and yet effective. I decided to use the Circuit Playground Express’s accelerometer to replace the WASD keys on the keyboard. All the player needs to do is tilt the controller forward to move up, right to move right, left to move left and down to move down. 

The player does not need to use any other keys except the mouse to start and pause the game. The whole game can be played with only the created controller. I did not want to use additional buttons like the potentiometer because this game is so simple and it is not needed. 


    I am happy with the results. At first I thought it might be a bit too boring but it turns out it is more fun than I expected. Using the accelerometer to control the direction is more challenging than using simple buttons and it adds additional fun to the overall gameplay experience. 

During the coding process, I had to tweak the sensitivity.  And due to the shape of the controller, I had to make the up sensor more sensitive due to it being more difficult to tilt the controller in that direction. Thus, I have no issues with precision which is very important in this type of game.


Question:


Aside from a Nokia phone design, what could I have used and would you have placed the PCE in place of the screen where the snake image is located?


Code:

  //Snake II by Nadia Al-Ghamdi #include <Keyboard.h> #include <Adafruit_CircuitPlayground.h> #include <Adafruit_Circuit_Playground.h> void setup() { CircuitPlayground.begin(); Keyboard.begin(); } void loop() { float y = CircuitPlayground.motionY(); float x = CircuitPlayground.motionX(); Serial.println(y); Serial.print(x); //up if (y <= -2) { Keyboard.press('w'); } //down if (y >= 5) { Keyboard.press('s'); } //left if(x >= 5) { Keyboard.press('a'); } //right if(x <= -5) { Keyboard.press('d'); } //release keys if ((y > -2) && (y < 5)) { Keyboard.release('w'); Keyboard.release('s'); } //release keys if ((x > -5) && (x < 5)) { Keyboard.release('a'); Keyboard.release('d'); } //fin }

 

Schematic:


 

No comments:

Post a Comment

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