So my controller aesthetically wants to match the game itself so what better way than that by making the controller look like the game itself, it makes the game which is usually dull of just clicking over and over with your mouse to now become a interactive game as we click the cookie in the game with a cookie itself outside of the game, so we put the cookie together with both halves to click on the cookie in the game meanwhile to just make it more interactive you have to break it apart everytime to make the cookie click again!
const int pResistor = A0:
const int xAxis = A1; //analog sensor for X axisconst int yAxis = A2; // analog sensor for Y axisint range = 12; // output range of X or Y movementint responseDelay = 2; // response delay of the mouse, in msint threshold = range / 4; // resting thresholdint center = range / 2; // resting position valueint minima[] = {1023, 1023}; // actual analogRead minima for {x, y}int maxima[] = {0, 0}; // actual analogRead maxima for {x, y}int axis[] = {xAxis, yAxis}; // pin numbers for {x, y}int mouseReading[2]; // final mouse readings for {x, y}void setup() {Mouse.begin(); //Lets me use the mouse functions!}void loop() {m = accelerometerMotionValuevalue = analogRead(pResistor);// read and scale the two axes:int xReading = readAxis(0);int yReading = readAxis(1);// move the mouse:if m > 1Mouse.move(xReading, yReading, 0); //Move right with tilt rightdelay(responseDelay);else if m < -1Mouse.move(xReading, yReading, 0); //Move left with tilt leftdelay(responseDelay);if (value < 25){Mouse.click(button); //click the mouse when the photoresistor is covered}}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.