Our controller is for the game Buckshot Roulette, a game about Russian roulette with a shotgun. In the game you choose to point the shotgun at yourself or at the enemy until your magazine is empty. Our controller is modeled like the shotgun in the game, allowing you to choose between the different options in the game through moving the mouse by aiming the shotgun. When the mouse is at the spot you want, you can cock back the shotgun, locking the mouse in place. When you want to click the mouse you can then press the trigger, clicking it. This concept relates to the game because of the shotgun in the game.


#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include <Mouse.h>
SET ACCEL_THRESHOLD = 5.0
SET LIGHT_DROP_LIMIT = 50
SET MOUSE_SPEED = 5
VARIABLE lastLightLevel
VARIABLE isLocked = FALSE
void setup() {
START CircuitPlayground hardware
START Mouse HID communication
INITIALIZE lastLightLevel = Read Light Sensor
SET Pin (Trigger) as INPUT_PULLUP
SET Pin (Recenter Button) as INPUT_PULLUP
}
void loop() {
VARIABLE currentLight = Read Light Sensor
if difference of last light level and current light level is greater than LIGHT_DROP_LIMIT
if(isLocked is FALSE)
Set isLocked to TRUE
else
Set isLocked to FALSE
if (isLocked is FALSE)
VARIABLE xAccel = Get Accelerometer X
VARIABLE yAccel = Get Accelerometer Y
if (xAccel is greater than ACCEL_THRESHOLD)
Move Mouse Left
else if (xAccel is less than -ACCEL_THRESHOLD)
Move Mouse Right
if (yAccel is greater than ACCEL_THRESHOLD)
Move Mouse Up
else if (yAccel is less than -ACCEL_THRESHOLD)
Move Mouse Down
if (Trigger Pin is LOW (Pressed))
Mouse Click (Left Button)
WAIT until Trigger is released
Set isLocked to FALSE
if (Recenter Pin is LOW (Pressed))
Move Mouse to the center of the screen
Set lastLightLevel to currentLight
Small Delay
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.