# Please help my Processing code. due to tomorrow!

**URL:** <https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725>\
**Category:** Libraries\
**Tags:** homework\
**Created:** [June 15, 2021, 3:18pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725 "2021-06-15T15:18:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![uniquenospace](https://avatars.discourse-cdn.com/v4/letter/u/e0b2c6/32.png) [@uniquenospace](https://discourse.processing.org/u/uniquenospace)\
**Post date:** [June 15, 2021, 3:18pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/1 "2021-06-15T15:18:59Z")

</div>

I want to make program that press the button on the first screen to play the first video, and when I press key ‘s’ or ‘l’ on the screen, I want to make them show different videos, but it’s too hard because I haven’t learned it yet.

```processing
import processing.video.*;
Movie myMovie;
Movie myMovie2;
Movie myMovie3;
int caseNum = 1;
Boolean btn1 = false;
Boolean btn2 = false;

void setup() {
  size(800, 600);
  myMovie = new Movie(this, "Movie01B.mp4");
  myMovie.play();
}

void draw() {
  image(myMovie, 0, 0);
  rect(90, 490, 35, 35, 7);
  fill(255);
  textSize(23);
  text("Start", 150, 515);
  if (mouseX>125 && mouseX<90 && mouseY>525 && mouseY<490) {
    btn1=true;
  } else {
    btn1=false;
  }
  
  switch(caseNum) {
  case 1:
   //fullScreen();
   image(myMovie, 0, 0);
   myMovie = new Movie(this, "Movie01B.mp4");
   myMovie.play();
   
  case 2:
   //fullScreen();
   image(myMovie2, 0, 0);
   myMovie2 = new Movie(this,"Movie02B.mp4");
   myMovie2.play();
   rect(90, 490, 35, 35, 7);
   fill(255);
   textSize(23);
   text("Play again", 150, 515);
   if (mouseX>125 && mouseX<90 && mouseY>525 && mouseY<490) {
     btn2=true;
   } else {
     btn2=false;
   }
   
  case 3:
    //fullScreen();
    image(myMovie3, 0, 0);
    myMovie3 = new Movie(this, "Movie03B.mp4");
    myMovie3.play();
  }
}

void keyPressed () {
  switch(caseNum) {
    case 1:
      if (key == 's') {
        caseNum = 2;
      }
      
    case 2:
      if (key == 'l') {
        caseNum = 3;
      }
       break;
  }
}

void mousePressed () {
  switch(caseNum) {
    case 1:
      if (btn1) {
        caseNum = 1;
      }
      break;
      
      case 2:
        if (btn2) {
          caseNum = 1;
        }
        break;
  }
}
  

void movieEvent(Movie m) {
  m.read();
}

```

please help! due to tomorrow…☹ ☹

---

<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:** [December 30, 2024, 9:09pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/3 "2024-12-30T21:09:20Z")

</div>

Welcome to the forum!

you are almost there!

- Load all movies in setup, nowhere else
- caseNum tells you which movie to show
- So instead of saying image(myMovie, 0, 0); at the start of draw(), so should use `switch(caseNum)` which you already have. Use it.
- start draw() with background(0);
- in mousePressed () is an error: caseNum = 1; occurs twice; one should be caseNum = 2;
- don’t use this myMovie.play(); in draw; I thik it restarts the video. Instead, use it where you change/start a video, in mousePressed or keyPressed.
- In the switch statements, you need to have break; after each case block!  
so this

```auto
 switch(caseNum) {
  case 1:
    if (key == 's') {
      caseNum = 2;
    }

  case 2:

```

must be

```auto
 switch(caseNum) {
  case 1:
    if (key == 's') {
      caseNum = 2;
    }
    break;

  case 2:

```

- Same in every switch block for every case
- When you don’t want the movie to start immediately, don’t say myMovie.play(); in setup.

---

<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:** [December 30, 2024, 9:25pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/4 "2024-12-30T21:25:57Z")

</div>

> [@uniquenospace](#):
>
> if (mouseX\>125 && mouseX\<90 && mouseY\>525 && mouseY\<490) {

this is a bit off.

Let’s write it like this:

```auto
if (mouseX>125 && 
    mouseX<90 && 
    mouseY>525 && 
    mouseY<490) {

```

or with a better order of the numbers:

```auto
if (mouseX<90 && 
    mouseX>125 && 
    mouseY<490 && 
    mouseY>525) {

```

Now we have the smaller number first (for mouseX, then for mouseY).

BUT:  
If mouseX is bigger than 125, it can’t be smaller than 90 at the same time.  
Same with mouseY.

So you mixed up \> and \< maybe?

---

<div class="post-metadata">

**Author:** ![ProcessingOrg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/processingorg/32/18341_2.png) [@ProcessingOrg](https://discourse.processing.org/u/ProcessingOrg)\
**Post date:** [January 8, 2025, 4:27pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/5 "2025-01-08T16:27:14Z")

</div>

Your post has been edited to format the code for better readability. Please review our [FAQ](https://discourse.processing.org/t/guidelines-asking-questions/2147#is-your-post-formatted-9) or refer to the animation below for guidance on posting code. Thank you!

![ezgif.com-gif-maker (1)](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/4/34521338de6902479873291389bf53a11d12237d.gif)

---

<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:** [January 8, 2025, 7:40pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/6 "2025-01-08T19:40:58Z")

</div>

Sorry, it was an old thread that popped up somehow.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 8, 2025, 9:16pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/7 "2025-01-08T21:16:10Z")

</div>

> [@Chrisir](#):
>
> it was an old thread that popped up somehow.

This answers the _somehow_:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/a/ea167ced7ab644026840a1a54c1253a20ae6d02e.png)

It moved to the top of the list after the edit.

Wonder if it was submitted by the deadline?

`:)`

---

<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:** [January 9, 2025, 1:31pm UTC](https://discourse.processing.org/t/please-help-my-processing-code-due-to-tomorrow/30725/8 "2025-01-09T13:31:17Z")

</div>

Thank you for our answer!

Chrisir
