# Making a Game "Launcher"

**URL:** https://discourse.processing.org/t/making-a-game-launcher/22281
**Category:** Coding Questions
**Created:** [June 30, 2020, 1:05pm UTC](https://discourse.processing.org/t/making-a-game-launcher/22281 "2020-06-30T13:05:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)
#### Post date: [June 30, 2020, 1:05pm UTC](https://discourse.processing.org/t/making-a-game-launcher/22281/1 "2020-06-30T13:05:03Z")

</div>

Is there any way to make something like a “launcher” in processing. What I mean by that is basically a main menu and when you click a button, it closes itself and opens another .exe file (or runs a processing source code which would be better).

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [June 30, 2020, 2:57pm UTC](https://discourse.processing.org/t/making-a-game-launcher/22281/2 "2020-06-30T14:57:38Z")

</div>

You can try using `launch()` or `exec()`. I have attached other posts that are relevant.

Kf

- [https://processing.org/reference/launch\_.html](https://processing.org/reference/launch_.html)
- [https://stackoverflow.com/questions/13991007/execute-external-program-in-java](https://stackoverflow.com/questions/13991007/execute-external-program-in-java)
- [https://forum.processing.org/two/discussion/20568/how-do-i-launch-a-compiled-sketch-from-within-another-sketch](https://forum.processing.org/two/discussion/20568/how-do-i-launch-a-compiled-sketch-from-within-another-sketch)
- [https://forum.processing.org/two/discussion/26485/launch-won-t-launch-my-compiled-processing-sketch](https://forum.processing.org/two/discussion/26485/launch-won-t-launch-my-compiled-processing-sketch)
- [How do i get the output of a command?](https://discourse.processing.org/t/how-do-i-get-the-output-of-a-command/769)

---

<div class="post-metadata">

### Author: ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)
#### Post date: [June 30, 2020, 3:06pm UTC](https://discourse.processing.org/t/making-a-game-launcher/22281/3 "2020-06-30T15:06:54Z")

</div>

Thanks! I’ll take a look.

---

<div class="post-metadata">

### Author: ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)
#### Post date: [July 1, 2020, 12:17pm UTC](https://discourse.processing.org/t/making-a-game-launcher/22281/4 "2020-07-01T12:17:17Z")

</div>

Thanks again!  
The solution here worked:

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/20568/how-do-i-launch-a-compiled-sketch-from-within-another-sketch)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

I made it so it launches when I click a button but it launches my application 2-5 times depending on how long the mouse stays on the button after clicking. It looks like it is a problem with my button. Here is my full code:

```auto
//PFont zigBlack;
int b1f = 140;
int b2f = 140;
int b3f = 140;
int b4f = 140;
int v1f = 200;
boolean versions = false;
boolean credits = false;
boolean controls = false;

void setup() {
  size(1200,600);
  //zigBlack = createFont("Minecraftia 2.0", 32);
  //textFont(zigBlack);
  frameRate(60);
  smooth();
}

void draw() {
  background(217,125,4);
  fill(0,140);
  rect(35,0,320,600);
  fill(255);
  textSize(45);
  text("The",400,105);
  text("Dungeons",400,160);
  text("Of The West",400,220);
  textSize(15);
  text("tDotW Launcher 1.0",1020,600);
  fill(0,b1f);
  rect(400,225,350,70);
  fill(0,b2f);
  rect(400,315,350,70);
  fill(0,b3f);
  rect(400,405,350,70);
  fill(0,b4f);
  rect(400,495,350,70);
  fill(255);
  textSize(25);
  text("Launch Game",420,286);
  text("Controls",420,376);
  text("Credits",420,466);
  text("Quit Launcher",420,556);
  
  if (versions == true) {
    fill(0,140);
    rect(800,0,360,600);
    fill(0,200);
    rect(800,0,360,30);
    
    fill(0,v1f);
    rect(800,45,360,100);
    
    fill(255);
    textSize(25);
    text("Version 1.0",810,93);
    textSize(15);
    text("Release Date: N/A",810,110);
    
    fill(255);
    textSize(15);
    text("Select a version",808,32);
  }
  
  if (controls == true) {
    fill(0,140);
    rect(800,0,360,600);
    fill(0,200);
    rect(800,0,360,30);
    fill(255);
    textSize(15);
    text("Controls",808,32);
  }
  
  if (credits == true) {
    fill(0,140);
    rect(800,0,360,600);
    fill(0,200);
    rect(800,0,360,30);
    fill(255);
    textSize(15);
    text("Credits",808,32);
  }
  
  if(mousePressed && mouseX>800 && mouseX<1160 && mouseY>45 && mouseY<145) {
    PrintWriter output=null;
    output = createWriter("myfile.bat");
    output.println("cd C:/Users/Lenovo/Desktop/Dungeon_Game/application.windows64/");
    output.println("start Dungeon_Game.exe");
    output.flush();
    output.close();  
    output=null;
    launch(sketchPath("")+"myfile.bat");
}
  if(versions == true && mouseX>800 && mouseX<1160 && mouseY>45 && mouseY<145) {
    v1f = 140;
  } else{
    v1f = 200;
  }
  
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295) versions = true;
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295 && credits == true) {
    credits = false;
    versions = true;
  }
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295 && controls == true) {
    controls = false;
    versions = true;
  }
  
  if(mouseX>400 && mouseX<750 && mouseY>225 && mouseY<295) {
    b1f = 200;
  } else{
    b1f = 140;
  }
  
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385) controls = true;
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385 && versions == true) {
    controls = true;
    versions = false;
  }
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385 && credits == true) {
    controls = true;
    credits = false;
  }
  
  if(mouseX>400 && mouseX<750 && mouseY>315 && mouseY<385) {
    b2f = 200;
  } else{
    b2f = 140;
  }
  
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475) credits = true;
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475 && versions == true) {
    credits = true;
    versions = false;
  }
  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475 && controls == true) {
    credits = true;
    controls = false;
  }
  
  if(mouseX>400 && mouseX<750 && mouseY>405 && mouseY<475) {
    b3f = 200;
  } else{
    b3f = 140;
  }

  if(mousePressed && mouseX>400 && mouseX<750 && mouseY>495 && mouseY<565) exit();
  
  if(mouseX>400 && mouseX<750 && mouseY>495 && mouseY<565) {
    b4f = 200;
  } else{
    b4f = 140;
  }
  
}

```

The “Version 1.0” button launches it (it appears when clicked on “Launch Game”). How can I fix this?

EDIT: Fixed it, my dumbness. Instead of if(mousePressed &&), I created a mouseClicked() void and put the stuff under that.
