i am trying to make blinds that when you click on the end of the string the, it follows the mouse location and when you pull the string down the blinds go up.. revealing a window.
i am currently stuck on making the string follow my mouse. if i mess with the background it either makes another square next to the original square or does nothing at all but erases the lines.
I am having trouble with buttons. I am trying to make it so red button stops the ball and green button continues moving the ball.
when i have only the first if statement, i can click anywhere on the screen and the ball will stop, i am trying to make it so only clicking the button makes it stop.
also when i add the second if statement, neither mousePressed action works.
I sat down with my professor for an hour after class and he could not spot my error, so he asked me to send it to him.
Cannot seem to figure this one out. I was having trouble with buttons so i am trying to figure them out, have been trying for 2 days and i havent moved from where i was. thanks in advance!
int x = 50;
int speed = 1;
void setup() {
size(400, 400);
}
void draw() {
background(255);
//set sllipse and rect to center
rectMode(CENTER);
ellipseMode(CENTER);
{//draw large rectangle
fill(255);
rect(200, 120, 390, 200);
}
{//draw red button
fill(255, 0, 0);
rect(50, 250, 50, 25);
}
{//draw green button
fill(0, 200, 0);
rect(150, 250, 50, 25);
}
{//draw blue button
fill(0, 0, 200);
rect(250, 250, 50, 25);
}
{//draw yellow button
fill(225, 225, 0);
rect(350, 250, 50, 25);
}
int x = 350;
int y = 250;
int w = 50;
int h = 25;
void mousePressed() {
if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h && mousePressed) {
int speed = 1;
} else {
int speed = 0;
}
}
// Add the current speed to the x location.
x = x + speed;
if ((x > width-30) || (x < 30)) {
// If the object reaches either edge, multiply speed by -1 to turn it around.
I am trying to make the red button stop the ball from moving, the green button starts movement again.
blue button when on turns dark blue and ball starts growing, light blue when OFF
Yellow button ON turn dark yellow and starts shrinking the ball
when off turns light yellow to start shrinking the ball.
Any help, tips or advice would be tremendously appreciated. I am reading the book and cant seem to figure this out.
My code so far is this...
int x = 50;
int speed = 1;
void setup() {
size(400,400);
}
void draw() {
background(255);
//set sllipse and rect to center
rectMode(CENTER);
ellipseMode(CENTER);
{//draw large rectangle
fill(255);
rect(200,120,390,200);
}
{//draw red button
fill(255,0,0);
rect(50,250,50,25);
}
{//draw green button
fill(0,200,0);
rect(150,250,50,25);
}
{//draw blue button
fill(0,0,200);
rect(250,250,50,25);
}
{//draw yellow button
fill(225,225,0);
rect(350,250,50,25);
}
// Add the current speed to the x location.
x = x + speed;
if ((x > width-30) || (x < 30)) {
// If the object reaches either edge, multiply speed by -1 to turn it around.