27 November 2023

Game Controller: Ender Lilies

 My controller was a bit of a scope failure on my end, it was too ambitious for someone as novice as me in terms of almost every aspect in its creation. Despite this I'm quite satisfied with how it turned out, generally speaking. The controller's design revolves around two halves, the flower, which controls command inputs, and the sword, which controls general movement around the game world, as well as healing.

Turning the sword handle either way will move the character in a certain direction, either left or right. Pushing the sword up or down will either use a healing prayer, if you push it upwards, or cause the player to look down. The latter input was chosen over other inputs because it allows the player to slam attack, which while awkward in this setup, is possible and necessary to advance in certain parts of the game.

The flower controls inputs based off of gesture, moving your hand in certain ways in front of the flower opposite the sword will cause one of several inputs to occur, jump, attack, dodge, and interact. These are all the inputs necessary to advance in the game, up to the point where I've actually played it. They include jumping, attacking, blocking/dodging, and interact/hook. These inputs are the bare minimum necessary to advance, with perhaps the exception of switching spirit sets over. This would have been controlled with other sensors initially, though this was found to be unfeasible as it was outside of my programming capabilities. Moreover the flower covers proved too much for the sensors to handle, so the final version needed its sensor mounted on the exterior.

Conceptually the sword is supposed to represent the knight, who is the guiding spirit that follows your character throughout the game, providing useful advice and encouraging your character as she travels. The flowers are meant to resemble the healing lilies found throughout the game, as well as tie back into the game's namesake. They also represent the player character, who is a young girl of upstanding purity, hence the white coloration. The game also sees the player control various spirits, who do all of the actual combat for you, so moving your hand around is comparable to commanding the spirits as you fight, and is actually the part of the controller I would most like to expand on given the opportunity.

I would like to ask of reviewers what I could do to make the inputs feel smoother, as it is somewhat awkward to control inputs through hand movement, and it can get tiring at times. So I would like to know if the gesture controls are acceptable or if they need refining/replacing. I would also like to know if more feedback would be necessary, the switch and potentiometer feel fine already, in that regard, so I would mostly be looking for suggestions when relating to the sensor(s).

I also would've liked to add a few buttons, one on the pommel for switching spirits, and either one or several on the handguard for using the several other minor spirits you can take with you, though the latter would also be possible if I were to better acquaintance myself with using multiple sensors.




#include <Adafruit_APDS9960.h>

#include <Keyboard.h>
#include <KeyboardLayout.h>
#include <Keyboard_da_DK.h>
#include <Keyboard_de_DE.h>
#include <Keyboard_es_ES.h>
#include <Keyboard_fr_FR.h>
#include <Keyboard_it_IT.h>
#include <Keyboard_sv_SE.h>


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

//Setup sensors, currently only 1
Adafruit_APDS9960 apds;

void setup() {
  // put your setup code here, to run once:

  //Begin CircuitPlayground, followed by apds1
  Serial.begin(9600);
  delay(100);
  apds.begin();

  //Enable proximity and gesture detection for apds1
  apds.enableProximity(true);
  apds.enableGesture(true);
  apds.setProximityInterruptThreshold(0, 255);


  //Setup Pins
  pinMode(A1,INPUT);
  pinMode(9,INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);

}

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

  //Setup Variables
  int turnVariable = analogRead(A1);
  int switchVariable1 = digitalRead(9);
  int switchVariable2 = digitalRead(10);

  //Serial.println(turnVariable);
  //First, we do the if statements for the switch(up/down input)
  if(switchVariable1 == 1 && switchVariable2 == 0)
  {
    Keyboard.release('w');
    Keyboard.press('s');
    delay(1);
  }

  if(switchVariable1 == 0 && switchVariable2 == 1)
  {
    /*Keyboard.release('s');
    Keyboard.press('w');*/
    Keyboard.println(',');
    delay(1);
  }

  if(switchVariable1 != 0 && switchVariable2 != 0)
  {
    Keyboard.release('w');
    Keyboard.release('s');
    delay(1);
  }

  //Next, are the switch statements for the potetiometer (left/right)
  if(turnVariable <= 350)
  {
    Keyboard.release('a');
    Keyboard.press('d');
    delay(1);
  }

  if(turnVariable >= 550)
  {
    Keyboard.release('d');
    Keyboard.press('a');
    delay(1);
  }

  if(turnVariable < 550 && turnVariable > 350)
  {
    Keyboard.release('a');
    Keyboard.release('d');
    delay(1);
  }
  uint8_t gesture = apds.readGesture();
    if(gesture == APDS9960_DOWN)
    {
      Keyboard.println("C");
      delay(25);
    }
    if(gesture == APDS9960_UP)
    {
      Keyboard.println("X");
      delay(25);
    }
    if(gesture == APDS9960_LEFT)
    {
      Keyboard.println("Z");
      delay(25);
    }
    if(gesture == APDS9960_RIGHT)
    {
      Keyboard.println("V");
      delay(25);
    }

  uint8_t proximityData = apds.readProximity();
  Serial.println(proximityData);

}

 








No comments:

Post a Comment

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