#rect() doesnt work in processing

1 messages ยท Page 1 of 1 (latest)

unborn heraldBOT
#

Detected code, here are some useful tools:

#

<@&987246452180930620> please have a look, thanks.

unborn heraldBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

drowsy leaf
#

Oh thats cool

#

It deleted my whole message bc i added a file

#

Oh Well Just wait a few minutes

#

It doesnt light up a random squares as it should do

#

It might something very obvious but im a begginner

#

Chess.pde

import java.util.Random;

final int WIDTH = 400;
final int HEIGHT = 400;
final int BLOCKX = WIDTH / 8;
final int BLOCKY = HEIGHT / 8;
 
void setup() {
  size(400, 400);
  noLoop(); 
  noStroke();
}
 
void draw() {
  for (int i = 0; i < 8; i ++) {
    for (int j = 0; j < 8; j ++) {
      if ((i + j + 1) % 2 == 0) {
        fill(255, 255, 220); // white
      } else {
        fill(63, 33, 4); // black
      }
      rect(i * BLOCKX, j * BLOCKY, (i + 1) * BLOCKX, (j + 1) * BLOCKY);     
    } 
  }
}


void mousePressed() {
  if (mousePressed) {
    Position p = new Position();
    Random r = new Random();
    p.letter = (char)(r.nextInt(8) + 'a');
    p.number = r.nextInt(8) + 1;
    p.lightUp();
  } 
}
unborn heraldBOT
# drowsy leaf Chess.pde ```java import java.util.Random; final int WIDTH = 400; final int HE...

Detected code, here are some useful tools:

Formatted code
import java.util.Random;

final int WIDTH = 400;
final int HEIGHT = 400;
final int BLOCKX = WIDTH / 8;
final int BLOCKY = HEIGHT / 8;
void setup() {
  size(400, 400);
  noLoop();
  noStroke();
}
void draw() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if ((i + j + 1) % 2 == 0) {
        fill(255, 255, 220);
        // white
      }
      else {
        fill(63, 33, 4);
        // black
      }
      rect(i * BLOCKX, j * BLOCKY, (i + 1) * BLOCKX, (j + 1) * BLOCKY);
    }
  }
}
void mousePressed() {
  if (mousePressed) {
    Position p = new Position();
    Random r = new Random();
    p.letter = (char ) (r.nextInt(8) + 'a');
    p.number = r.nextInt(8) + 1;
    p.lightUp();
  }
}
drowsy leaf
#

Position.pde

public class Position {
  char letter;
  int number;
  
  
  public void lightUp() {
    fill(0, 0, 0);
    rect((Character.getNumericValue(this.letter)-10)*50, this.number*50, 50, 50);
    println((Character.getNumericValue(this.letter)-10)*50, this.number*50);
    println(Character.getNumericValue(this.letter)-10, this.number);
    println(this.letter, this.number);
  }
}
unborn heraldBOT
# drowsy leaf Position.pde ```java public class Position { char letter; int number; ...

Detected code, here are some useful tools:

Formatted code
public class Position {
  char letter;
  int number;
  public void lightUp() {
    fill(0, 0, 0);
    rect((Character.getNumericValue(this .letter) - 10) * 50, this .number * 50, 50, 50);
    println((Character.getNumericValue(this .letter) - 10) * 50, this .number * 50);
    println(Character.getNumericValue(this .letter) - 10, this .number);
    println(this .letter, this .number);
  }
}
unborn heraldBOT
#

Closed the thread due to inactivity.

If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you ๐Ÿ‘