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 & HelpSyntax Questions › newbie help needed
Page Index Toggle Pages: 1
newbie help needed (Read 300 times)
newbie help needed
Oct 17th, 2006, 4:25pm
 
void setup() {
 size(200, 200);
 noLoop();
}
int a=mouseX;
int b=mouseY;
void mousePressed() {
 print(a);
 println(","+b);
 }
I wrote this code to get mouseX and mouseY values to be printed Im very new to this programing bussiness I tHink I somehow need to get the system recalculate the values endlessly I tried using loop() instead of noLoop() but didnt work also didnt work when wrote nothing any suggestions?
Re: newbie help needed
Reply #1 - Oct 17th, 2006, 4:57pm
 
Try this:

Code:
int a;
int b;

void setup() {
size(200, 200);
a=0;
b=0;
}

void draw()
{
a=mouseX;
b=mouseY;
}

void mousePressed() {
print(a);
println(","+b);
}
Re: newbie help needed
Reply #2 - Oct 17th, 2006, 5:12pm
 
thanx alot itwas probably nothing for you but a lot for me thx Smiley
Re: newbie help needed
Reply #3 - Oct 20th, 2006, 11:49pm
 
I came up with a new problem I think I'm learning fast Smiley
but here's the problem:
int x1;
int y1;
int x2;
int y2;
int w;
int r;
int g;
int b;
void setup() {
 size(800, 450);
 background(255, 255, 255);
 cursor(CROSS);
 noLoop();
}
void draw() {
stroke(r,g,b);
strokeWeight(w);
fill(r,g,b);
line(x1, y1,x2,y2);
line(-x1+800, y1,-x2+800,y2);
stroke(200);
strokeWeight(0);
line(400,0,400,450);
 }
void mouseDragged() {
 redraw();
 x2=mouseX;
 y2=mouseY;
 x1=pmouseX;
 y1=pmouseY;
 if (mouseButton == RIGHT){
   r=255;
   g=255;
   b=255;
   }
 }
void mousePressed() {
 redraw();
 x2=mouseX;
 y2=mouseY;
 x1=pmouseX;
 y1=pmouseY;
  if (mouseButton == RIGHT){
   r=255;
   g=255;
   b=255;
   }
 }
void keyPressed() {
 if (keyCode == ENTER) {
   saveFrame("screenshot##.png");
 }
 if (keyCode == UP) {
   w=w+1;
   }
 if (keyCode == DOWN) {
   if (w!=0){
   w=w-1;
   }
   }  
}
void mouseReleased(){
   noLoop();
   if (mouseButton == RIGHT){
   r=0;
   g=0;
   b=0;
   }
   }

I wrote acode for like a drawing program
what I want it to do is when I press r button and use right and left keys I want the r value to increase then when I press g and b buttons I wnat it to do this same thing for them. There is another problem though there is a
void mouseReleased(){
   noLoop();
   if (mouseButton == RIGHT){
   r=0;
   g=0;
   b=0;
   }
   }
code which would make all my values back to zero I want to use sth like saveString() and loadString() so that it saves the r g b values I give by increasing or decreasing and when I release the right button it goes back to the saved values.. is it too hard to do I dont know the logic seemed very possible to me but I dnt know how to code it exactly?????
Page Index Toggle Pages: 1