I’ve fixed the code below to cross off colors as they are matched. Yet, colors the player has already done, are somehow reviving / turning back on.
Load the following.
Double Click one blink once. Green “building”.
Double Click a second blink, two times. Red “Building”
Triple click a third blink. “Car”.
Match the color face on the car, to the corresponding building.
Single Click.
Matching color face on car goes off. Good. Expected.
take that same car to the next building. Attempt to repeat the process, … matching the car face to that building’s color.
Click
That matching light goes off. Good. Expected.
Previous light comes back on.
WHY.
Related
-
Single Clicking a blink, unattached, brings up the entire car, on it’s own. This is unexpected. Why?
-
Single Clicking a blink that is attached and clustered also brings up a garbled result that is not “Standard” car, four faces on one of each color, Face 2 and 5 off.
-
Thankfully I can’t reproduce it now, but I had a curly brace out of place in one load, and the entire string of blinks connected to the dev blink (and the dev blink itself) all loaded to “car” immediately after “teaching” was over. Why?
byte BuildingSend = 0;
byte BuildingColor = 0;
byte CarColor = 0;
Color CarColorList[4] = {CYAN, WHITE, ORANGE, MAGENTA};
Color BuildingColorList[4] = {GREEN, RED, YELLOW, BLUE};
byte GreenCrossed = 0;
byte RedCrossed = 0;
byte BlueCrossed = 0;
byte YellowCrossed = 0;
void setup() {
// put your setup code here, to run once:
//Main Street Pre-Alpha Feel-Around 06/23/21
//4 blinks in one row, connected. One blink for die. 4 blinks as cars. Each car has to go down "Main Street" to run errands on this very busy Saturday.
//Green Grocers, A Doctor's Appointment, The Post Office, and The Library. Roll Die. ROTATE blink over the top of Main Street, and over other cars (Traffic Jam)
// in effort to have your blink's face with the corresponding color match the given location's face, at the time they are there. First to unload all faces wins.
// Both directions of travel allowed, but turn is skipped if another blink is over-taking you.
//setColorOnFace(dim (WHITE, 50), 2);
//setColorOnFace(dim (WHITE, 50), 5);
//White to set up the double stripe lined road.
//Green Grocers, Doctor/Red, Post Office/Blue, Library / Yellow
setColor(OFF);
}
void loop() {
// ID Paint Color for "The Car"
if (buttonLongPressed()){
setColorOnFace(CarColorList[CarColor], 2);
setColorOnFace(OFF, 5);
CarColor = (CarColor + 1) % 4;
}
//Swap " List " between first and second "Building Color"
//Building Colors / Attractions
if (buttonDoubleClicked()){
setColorOnFace(BuildingColorList[BuildingColor], 0);
setColorOnFace(BuildingColorList[BuildingColor], 1);
setColorOnFace(BuildingColorList[BuildingColor], 3);
setColorOnFace(BuildingColorList[BuildingColor], 4);
setValueSentOnAllFaces(BuildingSend);
BuildingSend = (BuildingSend + 1) % 4;
BuildingColor = (BuildingColor + 1) % 4;
}
// The "Car"
if (buttonMultiClicked()){
if (GreenCrossed == 0);
{
setColorOnFace(GREEN, 0);
}
if (RedCrossed == 0);
{
setColorOnFace(RED, 1);
}
if (YellowCrossed == 0);
{
setColorOnFace(YELLOW, 3);
}
if (BlueCrossed == 0);
{
setColorOnFace(BLUE, 4);
}
}
//The Logistics
if (buttonSingleClicked())
{
if (getLastValueReceivedOnFace(0) == 0)
{
setColorOnFace (OFF, 0);
GreenCrossed = 1;
}
if (getLastValueReceivedOnFace(1) == 1)
{
setColorOnFace (OFF, 1);
RedCrossed = 1;
}
if (getLastValueReceivedOnFace(3) == 2)
{
setColorOnFace (OFF, 3);
YellowCrossed = 1;
}
if (getLastValueReceivedOnFace(4) == 3)
{
setColorOnFace (OFF, 4);
BlueCrossed = 1;
}
/// Added June 26
if (isValueReceivedOnFaceExpired(0))
{
if (GreenCrossed = 0);
{
setColorOnFace(GREEN, 0);
}
}
if (isValueReceivedOnFaceExpired(1))
{
if (RedCrossed = 0);
{
setColorOnFace(RED, 1);
}
}
if (isValueReceivedOnFaceExpired(3))
{
if (YellowCrossed = 0);
{
setColorOnFace(YELLOW, 3);
}
}
if (isValueReceivedOnFaceExpired(4))
{
if (BlueCrossed = 0);
{
setColorOnFace(BLUE, 4);
}
}
//// Remove entire block here if needed
//&& BuildingSend == 0
//&& BuildingSend == 1
//&& BuildingSend == 2
//&& BuildingSend == 3
}
}