For our game, the player takes up the role of a monster hunter tasked with slaying 4 infamous monsters, the vampire, the creature from the black lagoon, the wolfman, and Frankenstein's Monsters. As soon as it is plugged in, 4 colored lights will be displayed, each representing the monsters. Red = Vampire, Yellow = Wolfman, Blue = The Creature, and Green = Frankenstein. Each monster has a specific weakness that you must use to defeat them, and once you defeat them, the colored light will turn white. Once all the lights are white, a win animation will play to signify the players victory, and the game resets.
The vampire is weak to bright lights, the wolfman is weak to loud noises, the creature from the black lagoon is underwater and must be fished up using the dial (attached to the potentiometer) and Frankenstein will require you to turn off his electricity by flipping the switch connected to the board.
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
const int LEDpin = 13;
bool vampWhite = false;
bool wolfWhite = false;
bool frankWhite = false;
bool gillWhite = false;
void setup() {
pinMode(LEDpin, OUTPUT);
Serial.begin(9600);
delay(1000);
CircuitPlayground.begin();
}
void loop() {
bool allWhite = false;
// Vamp (Flash Light)
int vamp = analogRead(A8);
if (vamp > 300) {
vampWhite = true;
}
//Set Vamp Color
if (vampWhite) {
CircuitPlayground.setPixelColor(1, 255, 255, 255); // white
}
else {
CircuitPlayground.setPixelColor(1, 255, 0, 0); // red
}
// Wolf (Make Noise)
float wolf = CircuitPlayground.mic.soundPressureLevel(10);
if (wolf > 95) {
wolfWhite = true;
}
//Set Wolf Color
if (wolfWhite) {
CircuitPlayground.setPixelColor(3, 255, 255, 255); // white
} else {
CircuitPlayground.setPixelColor(3, 255, 239, 0); // yellow
}
// Frank (Flip Switch)
int frank = analogRead(A3);
if (frank < 50) {
CircuitPlayground.setPixelColor(6, 255, 255, 255); // white
frankWhite = true;
} else {
CircuitPlayground.setPixelColor(6, 0, 255, 0); // green
}
// Gill man (Turn Dial)
int gillman = analogRead(A1);
if (gillman < 50) {
CircuitPlayground.setPixelColor(8, 255, 255, 255); // white
gillWhite = true;
} else {
CircuitPlayground.setPixelColor(8, 0, 0, 255); // blue
}
// If all are white, it starts the win state
if (vampWhite && wolfWhite && frankWhite && gillWhite) {
allWhite = true;
}
// Win Animation
if (allWhite) {
// Spinning light animation
for (int i = 0; i < 10; i++) {
CircuitPlayground.clearPixels();
CircuitPlayground.setPixelColor(i, 0, 0, 255); //Blue
delay(500);
}
// Resets lights after animation
CircuitPlayground.clearPixels();
// Resets the states of all monsters
vampWhite = false;
wolfWhite = false;
frankWhite = false;
gillWhite = false;
}
// Displays status of Monster as game goes on
Serial.print(vampWhite);
Serial.print(" ");
Serial.print(wolfWhite);
Serial.print(" ");
Serial.print(frankWhite);
Serial.print(" ");
Serial.println(gillWhite);
delay(50);
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.