06 April 2022

Scaffolding: Game Controller Progress

The Knight Motion Controller™ is a motion controller designed for 2D games with basic controls but could be utilized for simplistic 3D games as well with a remapping of inputs. The game I chose is one of my own called Knightborn (controller is named after it), it has basic left to right movement, basic combat (left mouse button for attacking), and mouse cursor controls. With that in mind, I had to figure out some concepts of how to control all of those aspects with a single motion controller. My idea is for the Y axis to control left/right character movement and the X and Y axes for mouse control. I'm unsure if I'm going to use the Z axis, my plan is to use a sudden rise or lowering of the controller to trigger LMB.






PSEUDO CODE
/* PROJECT: GAME CONTROLLER
 *  
 * KNIGHT MOTION CONTROLLER
 * BY MATTHEW POWELL
 * 
 * TO BE USED WITH THE GAME KNIGHTBORN
 */

// LIBRARIES
#include <math.h>

// GLOBAL VARIABLES


void setup() {
  // SET UP SWITCH AS INPUT, BEGIN SERIAL, BEGIN CIRCUIT PLAYGROUND
  pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLDOWN);
  Serial.begin(9600);
  delay(1000);
  CircuitPlayground.begin();
}

void loop() {
  
  // SERIAL PRINT STRINGS
  Serial.print(x);
  Serial.print("\t");
  Serial.print(y);
  Serial.print("\t");
  Serial.print(z);
  Serial.print("\t");
  Serial.print(rad);
  Serial.print("\t");  
  
  // SWITCH TURNS CONTROLLER ON OR OFF
  // IF SWITCH IS OFF, DO NOTHING EXCEPT TURN OFF RED DIODE
  // ELSE
  // IF SWITCH IS ON, READ "VOID ON" FUNCTION & TURN ON RED DIODE
   
}

// CONTROLLER FUNCTIONALITY
void on () {
  
  // READ ACCELEROMETER XYZ & RADIAN
  float x = CircuitPlayground.motionX();
  float y = CircuitPlayground.motionY();
  float z = CircuitPlayground.motionZ();
  float rad = atan2(y, x);

  // Y AXIS MOVES CHARACTER/MOUSE LEFT/RIGHT

  // X AXIS MOVES MOUSE UP/DOWN

  // Z AXIS USED AS LMB, TRIGGERED BY SUDDEN RISE OR LOWER OF CONTROLLER

}

 

QUESTIONS

First thoughts on the design?

Any concerns you have with this motion controller concept?


No comments:

Post a Comment

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