Making a Variable Number of Stimuli Appear on Screen

As suggested in the title, I am trying to make a variable number of stimuli appear on the screen. Each trial I need a different (random within a range) number of squares to appear. (Five squares on one trial, seven squares another trial, etc). The trouble is I need them to all be presented at the same time.

I tried inserting a square stimuli, placing variables for the x and y coordinates, inserting a code block to manipulate the variables, and placing it in a loop repeating a variable number of times to get a different number of squares in each trial. This didn’t work because it won’t enter the next iteration of the loop until a routine is finished. This means I either have to give the stimuli a duration or choose an event to end it, both of which make the square disappear before it can formulate the next one. Is there a way for a routine to end but still leave its stimuli on the screen? Or is there a simpler way to build this so that the number of squares presented changes with each trial?

Thanks in advance for any help :smiley:

  • What is the range of the number of squares (i.e. minimum and maximum)?
  • What are the positions of the squares? e.g. do they vary or are they fixed? If they vary, in what way?