I need help making the numbers go into diferent rows instead of just one long row!

I need help making the numbers go into diferent rows instead of just one long row!

void setup() {

  size(1500, 600);
  background(0);

  for (int i = 0; i <= 99; i ++) {
    textSize(9);
    text(i, i * 14.9 + 10, 100);

    if (i < 99) {
      text(",", i * 14.95 + 18.5, 100);
    }
  }
  for (int j = 0; j <= 9; j ++) {
    text("0", j * 15 + 5, 100);
  }
}
Tagged:

Answers

  • Answer ✓

    See my last code

  • What last code?

  • You need to modify the y coord of the text () call to get the text to move down the screen.

  • @koogs what do you mean by "call"?

  • Text() is a method. When you use text() you are calling the method.

    The first parameter is the text to print, the second is the x position, the third is the y position. ALL your y positions are 100 so everything is on the same line.

  • edited April 2017

    so what do I do? :

    if( i >= 50) {
    
      text(i, i * 14.9 + 10, 200);
    }
    
  • edited April 2017

    Notice that in your own previous thread, you used two nested loops -- the outer loop would print a line, and the inner loop would print each number on a line.

    https://forum.processing.org/two/discussion/comment/94692/#Comment_94692

    Currently your text location changes horizontally with i*14.9 -- the inner loop counter variable. However, every single text appears at height 200 -- they are all on one line, no matter what. What if you made text change vertically as well, using an outer loop counter variable for the "y" argument of text, to change its height?

Sign In or Register to comment.