void Noble::randomMove() { randomizeDirections(); for(int i=0;i<4;i++) { if(direction[i]==1 && moveInDirection(getX(),getY()-1))//move north { break; } else if(direction[i]==2 && moveInDirection(getX(),getY()+1))//move south { break; } else if(direction[i]==3 && moveInDirection(getX()+1,getY()))//move east { break; } else if(direction[i]==4 && moveInDirection(getX()-1,getY()))//move west { break; } } }
void keyboardchar(int key) { switch (key) { case 'p': cout << "current list in eventBuffer: " << endl; eventBuffer.print(); cout << endl; cout << "Event[0] status: " << eventBuffer[0].getStatus() << endl; break; case '\\': direction *= -1; if (direction == 1) { cout << "Up" << endl; } else { cout << "Down" << endl; } break; case 'r': // random direction to current algorithms randomizeDirections(tparam); cout << "Random directions" << endl; break; case 'f': // normal direction of algorithms forwardDirections(tparam); cout << "Normal directions" << endl; break; case 'i': // invert direction of algorithms invertDirections(tparam); cout << "Inverted directions" << endl; break; case 'c': // reverse direction of algorithms reverseDirections(tparam); cout << "Changed directions" << endl; break; case 's': // increase rhythmic sensitivity tolerance = limit(tolerance * 1.02, 0.01, 0.99); cout << "Sensitivity = " << tolerance << endl; break; case 'x': // decrease rhythmic sensitivity tolerance = limit(tolerance / 1.02, 0.01, 0.99); cout << "Sensitivity = " << tolerance << endl; break; default: sillyKeyboard(key); } }