# Processing exam in 3 days: I can't finish my project

**URL:** https://discourse.processing.org/t/processing-exam-in-3-days-i-cant-finish-my-project/12556
**Category:** Libraries
**Created:** [July 7, 2019, 3:00pm UTC](https://discourse.processing.org/t/processing-exam-in-3-days-i-cant-finish-my-project/12556 "2019-07-07T15:00:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![edor97](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@edor97](https://discourse.processing.org/u/edor97)
#### Post date: [July 7, 2019, 3:00pm UTC](https://discourse.processing.org/t/processing-exam-in-3-days-i-cant-finish-my-project/12556/1 "2019-07-07T15:00:18Z")

</div>

Hello, I’m having really big troubles trying to figure out how to finish my project for my exam; here it is how I imagened it: in the first 10 seconds the screen should display the opening credits, after that part music and animation start; every 10 to 15 seconds i would like to play sound files and three image wich rapresent a conversation between two people ( 2 .png silhouette, one sound file for each person, and turn the background from black to an Image of a room) , while in the foreground the animation of the pulsing sound remain visible and in the same position.  
At the moment I’m completely stuck because I can’t find a way to display images behind the sound animation and then display each character line from their dialogue.

Here it is the code I wrote until now:

```auto

import ddf.minim.*;
import ddf.minim.analysis.*;

PFont f; //Dichiarazione del font 
Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;
int r = 100; //Valore di partenza del raggio del cerchio 
float rad = 70;
int m = millis();
PImage Stanza; //room
PImage Uomo1; //man1
PImage Uomo2; //man2

void settings(){
  size(1080, 720);
  smooth();

 

}

void setup(){
  
 
   
    background(0);
    PFont myFont = createFont("Arial-ItalicMT-48", 48);
    textFont(myFont);
    textSize(50);
    textAlign(CENTER);
    text("PROGETTO PROCESSING", width/2, 360); //Titolo del progetto //opening credits
    fill(255);
    
    textSize(30);
    textAlign(CENTER);
    text(".....................................", width/2, 500); //opening credits
    fill(255);

   

 minim = new Minim(this); //Inizializzazione del player

  player = minim.loadFile("loop midi.Wav"); //Carica file "loop midi.Wav" dalla cartella data dello sketch
  meta = player.getMetaData();
  beat = new BeatDetect(); //Rileva i battiti più rilevanti della canzone
  player.loop(); //La canzone gira in loop 
  //player.play();
 

   
    
  
}

void draw(){ 

  

  

  
  background(0); //Colore dello sfondo
  
  beat.detect(player.mix);
  fill(#1A1F18, 20);
  noStroke();
  rect(0, 0, width, height); //Grandezza della finestra della composizione 
  translate(width/2, height/2); //Posiziona la figura al centro della composizione 
  fill(-1, 10);
  if (beat.isOnset()) rad = rad*0.9;
  else rad = 70;
  ellipse(0, 0, 2*rad, 2*rad);
  stroke(-1, 50);
  int bsize = player.bufferSize();
  for (int i = 0; i < bsize - 1; i+=5)
  {
    float x = (r)*cos(i*2*PI/bsize);
    float y = (r)*sin(i*2*PI/bsize);
    float x2 = (r + player.left.get(i)*100)*cos(i*2*PI/bsize);
    float y2 = (r + player.left.get(i)*100)*sin(i*2*PI/bsize);
    line(x, y, x2, y2);
  }
  beginShape();
  noFill();
  stroke(-1, 50);
  endShape();
  
  
          for ( int m = 0; m > 1000; m++){ *strong text*
     if (player.length() > m){
       background(255);
   Stanza = loadImage("castle-european-interiors-68389.jpg");
   image(Stanza, 0, 0, 1080, 720);
   
     Uomo1 = loadImage("figura uomo 1.png");
   image(Uomo1, 200, 400, 138, 415);
  }
 }

```

I Hope someone could help me.  
Thanks.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 7, 2019, 3:20pm UTC](https://discourse.processing.org/t/processing-exam-in-3-days-i-cant-finish-my-project/12556/2 "2019-07-07T15:20:42Z")

</div>

In my opinion you can use a variable `state` of type int (declare state before `setup()`)

This state tells you the state / screen you are on

In draw() use `switch(state) { }` to evaluate state; nothing in draw() is allowed outside this `switch () {.....}` .

Say `state = 0;` in setup().

**How to go to the next state**

- In the state `0` display an intro message in `draw()`. Timer runs, then when it’s over say `state++;`

- When e.g. a song is over say once `state++;` (in minim use `if(!song.isPlaying)....` iirc)

- When you display an image use a timer and when it’s over say `state ++;`

Chrisir
