// Mouse & Keyboard Controls void keyPressed() { // make sure the mouse isn't clicked if (mousePressed == false) { // create a new stimulus of type 1 with strength 100 if (keyCode == DOWN) { G_totalStimuli.addStimulus(new Stimulus(mouseX, mouseY, 1, 100)); } // create a sensor that reads type 1 stimulus with a positive correlation if (keyCode == UP) { G_totalStimuli.addStimulus(new Stimulus(mouseX, mouseY, 2, 100)); } } } // ---------------------------------------------------------------------------------------------------------------- // if a stimulus is clicked on get that current stimulus int i_itemfoundTest = 1, i_currentItem; void mouseClicked() { for (int i = G_totalStimuli.sizeStimulus()-1; i > -1; i--) { if ((mouseX < G_totalStimuli.getlocationX(i)+10) && (mouseX > G_totalStimuli.getlocationX(i)-10)) { if ((mouseY < G_totalStimuli.getlocationY(i)+10) && (mouseY > G_totalStimuli.getlocationY(i)-10)) { i_itemfoundTest *= -1; i_currentItem = i; } } } }