# My sketch doesn't run, can anybody help me?

**URL:** <https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521>\
**Category:** Coding Questions\
**Created:** [June 10, 2025, 5:12pm UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521 "2025-06-10T17:12:37Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![HProcessing](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@HProcessing](https://discourse.processing.org/u/HProcessing)\
**Post date:** [June 10, 2025, 5:12pm UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/1 "2025-06-10T17:12:37Z")

</div>

```processing
int AH=4; // Anzahl der Memorykarten in der Höhe
int AB=6; // Anzahl der Memorykarten in der Breite
float rh; // Abstand zwischen dem Bildschirmrand und den Memorykarten in der Höhe
float rb; // Abstand zwischen dem Bildschirmrand und den Memorykarten in der Breite
float h; // Abstand zwischen rh 1 und rh 2
float b; // Abstand zwischen rb 1 und rb 2
float m; // Länge & Breite der Memorykarten
float a; // Abstand zwischen den Memorykarten

int value = 0; // ???
PImage[] img; // Bilderarray
int imnr = 0; // Bildnummer
int[] karten; // Kartenarray
int[] kartenstatus; /* 0: schwarze Seite der Karte wird gezeichnet, 1: Bild wird gezeichnet(= Karte aufgedeckt), 2: Kartenpaar wurde richtig aufgedeckt, 
 wird nicht mehr gezeichnet 
 */

// aufgedeckt;
void setup() {
  fullScreen();
  rh=height/10;
  rb=width/10;
  h=height - 2*rh;
  b=width - 2*rb;
  m=(b/(1.1*AB-0.1))*0.95;
  a=m/10; 

  kartenstatus = new int[AH*AB];
  for (int i=0; i<kartenstatus.length; i++) {
    kartenstatus[i]=0;
    draw();
  }

  kartenstatus[5] = 2;
}// Kartenstatus wird festgelegt
// To Do:

void draw () { 
  background (255);
  zeichneSchrift();
  imnr=0;
  zeichneMemorykarten();

  imageMode(CORNER) // Bilder werden geladen
    img = new PImage[18];

  for (int i=0; i<img.length; i++) {
    img[i]= loadImage ("Bilder/image"+i+".jpg");
  }
  karten = new int[AH*AB]; // Kartenpärchen werden zugeordnet
  for (int i = 0; i< karten.length; i++) {
    karten[i] = i/2;
  }

  for (int i=0; i<karten.length; i++) { // Karten werden mithilfe eines Zufallswertes durchmischt, bis jede Karte mindestens einmal getauscht wurde
    int x = int(random(AH*AB));
    int dummy = karten[i];
    karten[i] = karten[];
    karten[] = dummy;
  }
  for (int i=0; i<karten.length; i++) { // momentan noch zur Kontrolle, ob Durchmischungsprozess funktioniert
    print(" "+karten[i]);
  }
}
void zeichneSchrift () { // Schrift wird gezeichnet
  textSize(20);
  fill(0);
  text ("Spieler A", 30, 30);
  text ("gewonnene Paare:", 30, 60);
  text ("Spieler B", 956, 30); 
  text ("gewonnene Paare:", 956, 60);
}

void zeichneMemorykarten () {
  for (int i=0; i<AB; i++) {  
    for (int j=0; j<AH; j++) {
      if (kartenstatus[j*AB+i]==0) { // wenn der Kartenstatus 0 ist, wird die schwarze Seite der Karten gezeichnet
        stroke(255);
        fill(0);
        rect (rb+i*(m+a), rh+j*(m+a), m, m);
      } else if (kartenstatus[j*AB+i]==1) {// wenn der Kartenstatus 1 ist, wird das Bild gezeichnet; To Do: darf pro zug nur 2-mal durchlaufen!!!
        image (img[karten[j*AH+i]], rb+i*(m+a), rh+j*(m+a), m, m );
        imnr++;
        if (imnr>=18) imnr=0;
      }
    }
  }
}

void karteAnklicken(int x, int y) { // Kartenstatus einer Karte wird abgefragt
  if (kartenstatus[x*y]=0) kartenstatus[x*y] = 1;
  else kartenstatus[x*y]= 1;
}

mouseReleased(); 
{
  int x=-1;
  int y = -1;
  x= ((int)mouseX- (int)rb)/((int)m+(int)a);
  println(mouseX);
  y= ((int)mouseY- (int)rh)/((int)m+(int)a);
  println (mouseY);

  karteAnklicken(x, y);
}
}

```

/_that’s what’s written on the console:  
“expecting SEMI, found ‘img’  
Syntax error, maybe a missing semicolon?”_/

---

<div class="post-metadata">

**Author:** ![joshg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/joshg/32/20226_2.png) [@joshg](https://discourse.processing.org/u/joshg)\
**Post date:** [June 11, 2025, 2:25am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/2 "2025-06-11T02:25:01Z")

</div>

In processing, as with most programming languages, you have to explicitly include a multiplication sign between a constant and a variable. So for example, your line

```auto
h=height - 2rh;

```

leaves the compiler confused because it doesn’t understand what rh is doing there after the 2. Try

```auto
h=height - 2*rh;

```

and so on.

There might be other issues there too; try clicking on the ‘Errors’ tab on the bottom of the Processing app to see more.

---

<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:** [June 11, 2025, 9:52am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/3 "2025-06-11T09:52:06Z")

</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:** ![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:** [June 12, 2025, 2:03am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/4 "2025-06-12T02:03:46Z")

</div>

Hello @joshg,

> [@joshg](#):
>
> `h=height - 2rh;`

That is what happens when the do not format code properly when posting to the forum.

The admins have since cleaned it up.

This is the formatted code if it is just cut and paste into a sketch:

> **Unformatted code \< Click to expand!**
>
> int AH=4; // Anzahl der Memorykarten in der Höhe  
> int AB=6; // Anzahl der Memorykarten in der Breite  
> float rh; // Abstand zwischen dem Bildschirmrand und den Memorykarten in der Höhe  
> float rb; // Abstand zwischen dem Bildschirmrand und den Memorykarten in der Breite  
> float h; // Abstand zwischen rh 1 und rh 2  
> float b; // Abstand zwischen rb 1 und rb 2  
> float m; // Länge & Breite der Memorykarten  
> float a; // Abstand zwischen den Memorykarten
> 
> int value = 0; // ???  
> PImage img; // Bilderarray  
> int imnr = 0; // Bildnummer  
> int karten; // Kartenarray  
> int kartenstatus; /\* 0: schwarze Seite der Karte wird gezeichnet, 1: Bild wird gezeichnet(= Karte aufgedeckt), 2: Kartenpaar wurde richtig aufgedeckt,  
> wird nicht mehr gezeichnet  
> \*/
> 
> // aufgedeckt;  
> void setup() {  
> fullScreen();  
> rh=height/10;  
> rb=width/10;  
> h=height - 2_rh;  
> b=width - 2_rb;  
> m=(b/(1.1\*AB-0.1))\*0.95;  
> a=m/10;
> 
> kartenstatus = new int[AH\*AB];  
> for (int i=0; i\<kartenstatus.length; i++) {  
> kartenstatus[i]=0;  
> draw();  
> }
> 
> kartenstatus[5] = 2;  
> }// Kartenstatus wird festgelegt  
> // To Do:
> 
> void draw () {  
> background (255);  
> zeichneSchrift();  
> imnr=0;  
> zeichneMemorykarten();
> 
> imageMode(CORNER) // Bilder werden geladen  
> img = new PImage[18];
> 
> for (int i=0; i\<img.length; i++) {  
> img[i]= loadImage (“Bilder/image”+i+“.jpg”);  
> }  
> karten = new int[AH\*AB]; // Kartenpärchen werden zugeordnet  
> for (int i = 0; i\< karten.length; i++) {  
> karten[i] = i/2;  
> }
> 
> for (int i=0; i\<karten.length; i++) { // Karten werden mithilfe eines Zufallswertes durchmischt, bis jede Karte mindestens einmal getauscht wurde  
> int x = int(random(AH\*AB));  
> int dummy = karten[i];  
> karten[i] = karten;  
> karten = dummy;  
> }  
> for (int i=0; i\<karten.length; i++) { // momentan noch zur Kontrolle, ob Durchmischungsprozess funktioniert  
> print(" "+karten[i]);  
> }  
> }  
> void zeichneSchrift () { // Schrift wird gezeichnet  
> textSize(20);  
> fill(0);  
> text (“Spieler A”, 30, 30);  
> text (“gewonnene Paare:”, 30, 60);  
> text (“Spieler B”, 956, 30);  
> text (“gewonnene Paare:”, 956, 60);  
> }
> 
> void zeichneMemorykarten () {  
> for (int i=0; i\<AB; i++) {  
> for (int j=0; j\<AH; j++) {  
> if (kartenstatus[j_AB+i]==0) { // wenn der Kartenstatus 0 ist, wird die schwarze Seite der Karten gezeichnet  
> stroke(255);  
> fill(0);  
> rect (rb+i_(m+a), rh+j\*(m+a), m, m);  
> } else if (kartenstatus[j_AB+i]==1) {// wenn der Kartenstatus 1 ist, wird das Bild gezeichnet; To Do: darf pro zug nur 2-mal durchlaufen!!!  
> image (img[karten[j_AH+i]], rb+i\*(m+a), rh+j\*(m+a), m, m );  
> imnr++;  
> if (imnr\>=18) imnr=0;  
> }  
> }  
> }  
> }
> 
> void karteAnklicken(int x, int y) { // Kartenstatus einer Karte wird abgefragt  
> if (kartenstatus[x_y]=0) kartenstatus[x_y] = 1;  
> else kartenstatus[x\*y]= 1;  
> }
> 
> mouseReleased();  
> {  
> int x=-1;  
> int y = -1;  
> x= ((int)mouseX- (int)rb)/((int)m+(int)a);  
> println(mouseX);  
> y= ((int)mouseY- (int)rh)/((int)m+(int)a);  
> println (mouseY);
> 
> karteAnklicken(x, y);  
> }  
> }

The `*` is a problem because Processing Discourse uses Markdown, where `*` denotes italics or bold. This can mess up code formatting unless it’s properly enclosed in code blocks.

`:)`

---

<div class="post-metadata">

**Author:** ![joshg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/joshg/32/20226_2.png) [@joshg](https://discourse.processing.org/u/joshg)\
**Post date:** [June 13, 2025, 2:16am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/5 "2025-06-13T02:16:31Z")

</div>

Ah, that makes sense! I didn’t realize this forum supports Markdown.

OP, looks like you’re just missing a semicolon in this line:  
`imageMode(CORNER) // Bilder werden geladen`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2025, 2:32am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/6 "2025-06-13T02:32:58Z")

</div>

Even after that I can’t run the posted code on a Mac:  
`Syntax Error - editor.status.error_on`  
I have no idea how to fix that.

---

<div class="post-metadata">

**Author:** ![joshg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/joshg/32/20226_2.png) [@joshg](https://discourse.processing.org/u/joshg)\
**Post date:** [June 13, 2025, 2:37am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/7 "2025-06-13T02:37:08Z")

</div>

That error message is pretty cryptic!

Hrm, it really is weird that the IDE isn’t jumping to the error on trying to run.

If you go to the error panel, you can click on the error to jump to what’s causing a problem. The weird ‘editor.status.error\_oasdfsadfsadf’ ones seem to refer to a mismatch of accessing array variables with or without an index, eg. `karten[i] = karten[];`

The mouseReleased function is also formatted poorly and won’t run; it needs ‘void’ and some correct punctuation around it.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2025, 2:46am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/8 "2025-06-13T02:46:35Z")

</div>

On a Mac my error panel is empty; which operating system are you using? There are lots of problems with the code and I finally gave up.

 ![ep](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/7/a7b17d343cf456b263e6364ff3a56623c931aaf4.png)

**Addendum:**  
Just found out that it’s a lot easier to debug in Windows11; I actually got it to run. Makes a big difference if you get some help from the editor.

---

<div class="post-metadata">

**Author:** ![joshg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/joshg/32/20226_2.png) [@joshg](https://discourse.processing.org/u/joshg)\
**Post date:** [June 13, 2025, 3:47am UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/9 "2025-06-13T03:47:57Z")

</div>

Well that’s even weirder. I’m on Linux at the moment.

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [June 13, 2025, 5:15pm UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/10 "2025-06-13T17:15:05Z")

</div>

Hey, thanks for sharing your code!

There are a few issues preventing your sketch from running as expected:

- First, you’re calling `draw();` manually inside `setup()`, which isn’t necessary. Processing calls it in a loop automatically.
- Second, you’re loading images inside `draw()`. That means they will be loaded every frame. That should happen only once in `setup()`.
- There are some more syntax errors throughout, including missing semicolons and other issues.

I’d recommend reviewing how `setup()` and `draw()` are intended to work in Processing, and moving your image loading and initialization logic out of `draw()`. Once those things are fixed, the rest should be easier to debug.

---

<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:** [June 13, 2025, 5:23pm UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/11 "2025-06-13T17:23:26Z")

</div>

Hello @sableraph,

I was just looking at this code as a morning exercise for my brain!

And your response popped in!

I call that _electromagnetic waves propagating through space_… and I picked up on them!

There are many errors indeed!

Just one more that I am leaving as an exercise for the original poster:

> [@HProcessing](#):
>
> ```auto
> mouseReleased(); 
> {
> // Code removed...
> }
> 
> ```

Reference:

> **[mouseReleased() / Reference](https://processing.org/reference/mousereleased_)**
>
> The mouseReleased() function is called every time a mouse button is released. Mouse and keyboard events only work when a program has draw(). Without draw(), the code i…

`:)`

---

<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:** [June 13, 2025, 5:55pm UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/12 "2025-06-13T17:55:17Z")

</div>

> [@joshg](#):
>
> it really is weird that the IDE isn’t jumping to the error on trying to run.

It seems to work with Processing 3.5.4

I believe something is broken now in the recent versions.

I did not find an issue here but may have missed something:

> **[Issues · processing/processing4](https://github.com/processing/processing4/issues)**
>
> Source code for the Processing Core and Development Environment (PDE) - Issues · processing/processing4

`:)`

---

<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:** [June 25, 2025, 6:26pm UTC](https://discourse.processing.org/t/my-sketch-doesnt-run-can-anybody-help-me/46521/13 "2025-06-25T18:26:45Z")

</div>

Update on error reporting:

> [@Processing doesn't say where the error is](https://discourse.processing.org/t/processing-doesnt-say-where-the-error-is/46411/6):
>
> FYI this didn’t get forgotten, and it’s being looked in to.
