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 › size() background() > initialization ERROR
Page Index Toggle Pages: 1
size() background() > initialization ERROR (Read 755 times)
size() background() > initialization ERROR
Oct 5th, 2006, 5:50pm
 
I have a simple random walk program.
It has 2 random walkers starting from the center.
It has been simplified here to isolate the bug.
(Processing - 0118 Beta, Windows XP)

It is kind of working, but when I run it,
most of the time
-- the window size is wrong,
-- the drawing size is different,
-- the background color is wrong,
-- the starting points are wrong.

Is this a bug, or is my code wrong ?

Here is the code:
---------------------------------------
Walker w1,w2;

void setup() {
 size(1590,1100);
 colorMode(RGB,255);
 background(215,200,210);
 frameRate(200);

 // Create walkers
 w1 = new Walker(width/2,height/2);
 w2 = new Walker(width/2,height/2);
}

void draw() {
 // Run walkers
 w1.walk();
 w1.render(75,150,225,75);
 w2.walk();
 w2.render(75,225,150,75);
}
---------------------------------------
class Walker {
 int x,y;

 Walker(int x0, int y0) {
   x = x0;
   y = y0;
 }

 void render(int st1, int st2, int st3, int alp) {
   stroke(st1,st2,st3,alp);
   point(x,y);
 }

 // Randomly move (x,y)
 void walk() {
   int vx = int(random(3))-1;
   int vy = int(random(3))-1;
   x += vx;
   y += vy;

 }
}
---------------------------------------
Re: size() background() > initialization ERROR
Reply #1 - Oct 5th, 2006, 8:18pm
 
what happens if you remove the frameRate() command?
Re: size() background() > initialization ERROR
Reply #2 - Oct 6th, 2006, 6:45am
 
It's the same, if I remove the frameRate() command.
Page Index Toggle Pages: 1