I'm taking a basic programming course at my university and I just startet programming a month ago. To complete my course, I have to hand in a psychological program which I programmed myself. I've chosen for the "Ponzo Illusion Task" and I already began with it some time ago. For those who do not know the
"Ponzo Illusion Task": you get 2 lines, one is of fixed random length, the other one is manipulable by the participant. The participant's task is to make both lines equally long. This process is hindered by some background lines which make it difficult to simply compare the lengths of the lines. I set up the background lines and programmed some buttons, which I want to use later (actually I do not want to use keys, but simply the eventhandler 'mousePressed', but I use the keys for now) and I started programming the 2 lines. I somehow used the command "rect" with the Center-mode and with h=0 for these lines, because it's simpler to make the lines longer or shorter. I also began to program that the second line (I simply call it rect2 from now on) becomes shorter when I press key 's', but it simply does nothing... When I press 'l' for longer, .... it's becoming longer, but I cannot find my mistake in the shorter part... Can someone please help me with that? This might be a simple question, but I'm only a beginner tho.
Thanks in advance!
This is my code:
//Defining global variables int canvasWidth = 600; int canvasHeight = 600; //variables for vertical lines float lineX1 = canvasWidth/2; float lineY1 = canvasHeight/8; float lineY2 = canvasHeight * 6/8; color bgColor = color (255,255,255); color lineColor = color (0,0,0); float dist = 50; //Distance between vertical lines
//Declaration and creation of the array to hold the values for the X2 coordinates of the vertical lines float [] arrayOfLineX2 = {lineX1,lineX1-dist,lineX1+dist,lineX1-2*dist,lineX1+2*dist,lineX1-3*dist,lineX1+3*dist};
// variables for randomly given horizontal line float rectX1 = 300; float rectY1 = 275; float rectW1 = random(110,160);
// variables for horizontal line that user can change in every trial float rectY2 = 350; float rectW2 = 130; boolean shorterbutton = false;
// values for both horizontal lines float rectH = 0;
//draw rectangle with height 0 to draw the randomly given horizontal line, use CENTER-Mode for making width change possible (for each trial) rectMode(CENTER); rect(rectX1,rectY1,rectW1,rectH);
//draw 2nd rectangle with height 0 to draw the horizontal line that user can change in every trial rectMode(CENTER); rect (rectX1, rectY2, rectW2, rectH); }