Loading...
Logo
Processing Forum

[Super Noob] Reflex-Testing program?

in General Discussion  •  Other  •  11 months ago  

So, I'm having a bit of a problem with an assignment and I hope you guys could maybe point me in the right direction.

This is the assignment:

A box on the screen should use an associated speed variable to change its color randomly between six different colors, one of which is red. After one minute, a reflect rating report should be displayed showing the number of times red appeared, the number of successful clicks on red, and the number of unsuccessful non-red clicks.

I'm sorry if this is against the rules but I'm kinda lost here.

Replies(2)

well, no one is going to do the assignment for you, but i think asking for help isn't a big deal. these forums exist to help us share knowledge.

so, with that being said, i'll talk generally about some ideas that might help you formulate a solution.

so, lets break this problem down.

variables you'll need:

speed (getting speed from the mouse might be a really easy way to put a value here, you can look that up here: http://processing.org/reference/mouseX.html)
color (six different colors: http://processing.org/reference/color_datatype.html)
a boolean (a true/false variable) to indicate whether your desired color was clicked on : http://processing.org/reference/boolean.html

an integer to store how many times your boolean was indicated as true.

so, one way you might go about doing the assignment is tracking the speed of your mouse. have the box ( http://processing.org/reference/rect_.html) change colors ( http://processing.org/reference/fill_.html) based on the speed of your mouse. now, if you happen to click your mouse ( http://processing.org/reference/mousePressed_.html) while the color is your desired color (doing a simple if comparison: http://processing.org/reference/if.html), then increment your counter by one.

so, hopefully that conceptually helps you break down the problem into smaller chunks that you can research and learn about on your own. The best way (in my opinion) to learn programming is to focus on one small part of the problem at a time.
So, first solve the problem: "how do i get a speed variable to change?"
then "how do i get colors to change based on speed?"
then move on to "how can i tell if a color matches the desired color when i click?"
and finally "how do i store the results?"

just treat them as four individual problems, and as you solve each one you'll find that you make your way towards the total solution.

If you were hoping for code, well, sorry. But if you were looking for a direction to start working in, then I hope this helps

-j


/*
thinking about learning how to think in order to more effectively learn
*/
Hello,

I go along with zombience. Here the basics:  http://www.processing.org/learning/basics/

Here is my version of a result, but I not recommend to copying the code. It's a tricky solution.

Copy code
  1. int time, changes, clicks, counter, hits, state;
  2. color[] c;

  3. void setup(){
  4.   size(200,200);
  5.   background(255);

  6.   c = new color[6];
  7.   c[0] = color(255,0,0);  // red
  8.   c[1] = color(0,255,0);
  9.   c[2] = color(0,0,255);
  10.   c[3] = color(255,255,0);
  11.   c[4] = color(255,0,255);
  12.   c[5] = color(0,255,255);
  13. }

  14. void draw(){
  15.   background(c[state]);
  16.   if(millis()>time){
  17.     changes++;
  18.     state=round(random(0,c.length-1));
  19.     counter+=(state==0)?1:0;
  20.     time=millis()+floor(random(25,75)*10); // frequency of switch 
  21.   }
  22.   if(millis()>60000){
  23.     noLoop();
  24.     println("changes: "+changes);
  25.     println("clicks: "+clicks);
  26.     println("counter: "+counter);
  27.     println("hits: "+hits);
  28.   }
  29. }

  30. void mousePressed(){
  31.   clicks++;
  32.   if(state==0){
  33.     hits++;
  34.     time=0; 
  35.   }
  36. }
Happy coding, Darius

Edit: Oh, I mistaked a little bit the exercise, forget it! ;-)