# How to create shuffling effect when mouse pressed and choose one when mouse is released

**URL:** <https://discourse.processing.org/t/how-to-create-shuffling-effect-when-mouse-pressed-and-choose-one-when-mouse-is-released/25054>\
**Category:** Coding Questions\
**Created:** [October 30, 2020, 5:50pm UTC](https://discourse.processing.org/t/how-to-create-shuffling-effect-when-mouse-pressed-and-choose-one-when-mouse-is-released/25054 "2020-10-30T17:50:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ljna227](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@ljna227](https://discourse.processing.org/u/ljna227)\
**Post date:** [October 30, 2020, 5:50pm UTC](https://discourse.processing.org/t/how-to-create-shuffling-effect-when-mouse-pressed-and-choose-one-when-mouse-is-released/25054/1 "2020-10-30T17:50:45Z")

</div>

So I have an array of pictures and another array of names of the pictures. When the mouse is pressed, the names and pictures appear on the screen and shuffles. When the mouse is realeased, it stops at one image and corresponding name. First, I don’t know how to show image and corresponding name when the mosue is released.

```auto
boolean shuffle= false;
int num= int(random(0,8));
void draw() {
  //if im cycling through the pictures, it shows this
  if(shuffle){
   fill(0);
  image(img[int(random(0,img.length))], 0, 0);
  rect(width/2, 0, width/2, height);
  fill(255,0,0);
  textFont(f,40);
  text(names[int(random(0,names.length))],800,400);
  }
  else if(!shuffle){
    background(0);
    image(img[num],0,0);
    text(names[num],800,400);
  }
  }

```
