We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Help on a little Program.
Page Index Toggle Pages: 1
Help on a little Program. (Read 536 times)
Help on a little Program.
Jan 21st, 2008, 6:31pm
 
Hi,
I´ve been searching/ testing for hours, but i can´t write a functionally programm, which draws with for/while points on the window.
For instance the first point should be drawed at position 0,0 then the program should draw points with a distance of 10 pxl, till the window is full. And this horizontal and vertical.
Sry for my "bad" English, i hope you can understand my problem.

Your help is appreciated, Thanks.

Re: Help on a little Program.
Reply #1 - Jan 21st, 2008, 7:46pm
 
post your code so we can see where is your mistake!

here is something which might help :

Code:
background(255); stroke(0);
for (int x = 0; x < width; x += 10) {
for (int y = 0; y < height; y += 10) {
point(x, y);
}
}
Re: Help on a little Program.
Reply #2 - Jan 21st, 2008, 8:11pm
 
Hi, thx.
The thing with for is no problem, but i can´t get my while program to go.
I´ve tested several possibilties, but i don´t know what´s wrong.

int x=0;
int y=0;
while (x<80){
point(x,y);
 x=x+5;
while (y<80) {
 point(x,y);
  y=y+5;
}}
Re: Help on a little Program.
Reply #3 - Feb 1st, 2008, 8:29pm
 
Hope this helps?

int x=0;
int y=0;
while (x<80){
 point(x,y);
 while (y<80){
   point(x,y);
   y+=5;
 }
x+=5;
y=0;
}

-r
Re: Help on a little Program.
Reply #4 - Feb 2nd, 2008, 12:51am
 
Have you put the proper structure around your code ?
You need a setup() method and a  draw() method.

Try the following:

void setup() {
 size(300,300);
 background(153);
 noLoop();
}//setup()

void draw() {
 int x=0;
 int y=0;
 while (x<80){
   point(x,y);
   x=x+5;
   while (y<80) {
     point(x,y);
     y=y+5;
   }
 }
}//draw()
Page Index Toggle Pages: 1