PApplet.runSketch trying to access java class in my sketch from a java file inside a folder

104 Views Asked by At

I'm trying to create a program that allows you to run multiple sketches off of one master sketch through using the PApplet.runSketch function. This has posed the best option for me but I want to be able to access a collection of java files within multiple folders for better organization of the games. The problem is I have no idea how to do so within the constraints of the function and when I search for pre-existing examples, none properly solve it the way I'd like.

Reason for wanting folders instead of multiple tabs:
The folders would be saved in the same folder alongside my main sketch.pde. The problem with using multiple tabs is that I have games that use up to 5-8+ tabs and that would eventually just clutter everything. So I'm looking for a way to store games in individual folders and then access within my main sketch.pde each individual game's main java file

Here's my code
\sketch.pde

void settings() {
  size(600, 200);
}

void setup() {
  String args[] = {
    "--display=1",
    "--location=0,0",
    "--sketch-path=" + sketchPath("Game1"),
    "Game1"
  };
  Game1 g = new Game1(320, 420);
  PApplet.runSketch(args, g);
}

void draw() {
  background(0);
  ellipse(50, 50, 10, 10);
}

\Game1\Game1.java

import processing.core.*;

public class Game1 extends PApplet {
  
    private final int w, h;

    public Game1(int w, int h) {
        this.w = w;
        this.h = h;
    }

    public void settings() {
        size(this.w, this.h);
    } 

    public void draw() {
        background(0);
    }

}

The problem is that the Game1 class is not recognized because the Game1.java file is within a folder and not present with the sketch.pde, but that is how I want to be able to run the sketches. Any ideas?

0

There are 0 best solutions below