i need help finishing my project!!!
in
Programming Questions
•
7 months ago
this is what my project should look like but i have no clue how to use if and else and booleans correctly. need help
http://www2.sunysuffolk.edu/struckc/CST112/applets/Project4/
and this is my codes
//// The x- and y-coordinates
int x=159;
int y=0;
//The direction and speed
int speed = 1;
int moveX =1;
int moveY=1;
//colors
int myWhite= 255;
//declare a variable boolean
boolean toggleSwitch = false;
void setup()
{
size(300,400);
smooth();
}
void draw()
{
//clear the screen
background(myWhite);
strokeWeight(3);
stroke(0);
fill(255);
//right ear
beginShape();
curveVertex(x+30,y+100);
curveVertex(x+10,y-40);
curveVertex(x+50,y-60);
curveVertex(x+50,y-20);
curveVertex(x+60,y+100);
endShape();
//left ear
beginShape();
curveVertex(x-30,y+100);
curveVertex(x-10,y-40);
curveVertex(x-50,y-60);
curveVertex(x-50,y-20);
curveVertex(x-60,y+100);
endShape();
//feet
fill(255);
ellipse(x-20,y+110,40,40);
ellipse(x+20,y+110,40,40);
//right hand
fill(255);
ellipse(x+40,y+60,26,26);
ellipse(x+52,y+55,10,10);
noStroke();
rect(x+42,y+50,10,12);
stroke(0);
fill(250,68,211);
triangle(x+20,y+40,x+20,y+70,x+50,y+50);
//left hand
fill(255);
ellipse(x-40,y+60,26,26);
ellipse(x-52,y+55,10,10);
noStroke();
rect(x-51,y+50,10,12);
stroke(0);
fill(250,68,211);
triangle(x-20,y+40,x-20,y+70,x-50,y+50);
//body
fill(255,0,0);
quad(x-40,y+110,x+40,y+110,x+30,y+40,x-30,y+40);
fill(250,68,211);
ellipse(x,y+50,30,30);
//head
fill(255);
ellipse(x,y,120,100);
noStroke();
fill(255);
rect(x-47,y-50,32,30);
rect(x+17,y-50,32,30);
//right eye
fill(0);
ellipse(x+30,y+5,10,12);
//left eye
noFill();
stroke(0);
arc(x-30,y+5,12,7,radians(10),radians(170));
//noise
stroke(0);
fill(255,200,10);
ellipse(x,y+20,15,10);
//right whisker
line(x+50,y,x+70,y-5);
line(x+50,y+10,x+70,y+12);
line(x+47,y+20,x+67,y+30);
//left whisker
line(x-50,y,x-70,y-5);
line(x-50,y+10,x-70,y+12);
line(x-47,y+20,x-67,y+30);
//bow
fill(255,0,0);
beginShape();
curveVertex(x+20,y-100);
curveVertex(x+30,y-45);
curveVertex(x+55,y-15);
curveVertex(x+70,y-50);
curveVertex(x+65,y-60);
endShape(CLOSE);
beginShape();
curveVertex(x+20,y-90);
curveVertex(x+30,y-45);
curveVertex(x+5,y-25);
curveVertex(x,y-40);
curveVertex(x+10,y-66);
curveVertex(x+40,y-80);
endShape(CLOSE);
fill(200,25,25);
ellipse(x+20,y-43,10,10);
ellipse(x+49,y-35,10,10);
fill(255,0,0);
ellipse(x+35,y-40,25,25);
//move the object
x= x+ speed;
y= y+ speed;
//change directions
if (x <= 1 )
{
speed = -speed;
}
else if (y>= 150 )
{
speed = - speed;
}
}
http://www2.sunysuffolk.edu/struckc/CST112/applets/Project4/
and this is my codes
//// The x- and y-coordinates
int x=159;
int y=0;
//The direction and speed
int speed = 1;
int moveX =1;
int moveY=1;
//colors
int myWhite= 255;
//declare a variable boolean
boolean toggleSwitch = false;
void setup()
{
size(300,400);
smooth();
}
void draw()
{
//clear the screen
background(myWhite);
strokeWeight(3);
stroke(0);
fill(255);
//right ear
beginShape();
curveVertex(x+30,y+100);
curveVertex(x+10,y-40);
curveVertex(x+50,y-60);
curveVertex(x+50,y-20);
curveVertex(x+60,y+100);
endShape();
//left ear
beginShape();
curveVertex(x-30,y+100);
curveVertex(x-10,y-40);
curveVertex(x-50,y-60);
curveVertex(x-50,y-20);
curveVertex(x-60,y+100);
endShape();
//feet
fill(255);
ellipse(x-20,y+110,40,40);
ellipse(x+20,y+110,40,40);
//right hand
fill(255);
ellipse(x+40,y+60,26,26);
ellipse(x+52,y+55,10,10);
noStroke();
rect(x+42,y+50,10,12);
stroke(0);
fill(250,68,211);
triangle(x+20,y+40,x+20,y+70,x+50,y+50);
//left hand
fill(255);
ellipse(x-40,y+60,26,26);
ellipse(x-52,y+55,10,10);
noStroke();
rect(x-51,y+50,10,12);
stroke(0);
fill(250,68,211);
triangle(x-20,y+40,x-20,y+70,x-50,y+50);
//body
fill(255,0,0);
quad(x-40,y+110,x+40,y+110,x+30,y+40,x-30,y+40);
fill(250,68,211);
ellipse(x,y+50,30,30);
//head
fill(255);
ellipse(x,y,120,100);
noStroke();
fill(255);
rect(x-47,y-50,32,30);
rect(x+17,y-50,32,30);
//right eye
fill(0);
ellipse(x+30,y+5,10,12);
//left eye
noFill();
stroke(0);
arc(x-30,y+5,12,7,radians(10),radians(170));
//noise
stroke(0);
fill(255,200,10);
ellipse(x,y+20,15,10);
//right whisker
line(x+50,y,x+70,y-5);
line(x+50,y+10,x+70,y+12);
line(x+47,y+20,x+67,y+30);
//left whisker
line(x-50,y,x-70,y-5);
line(x-50,y+10,x-70,y+12);
line(x-47,y+20,x-67,y+30);
//bow
fill(255,0,0);
beginShape();
curveVertex(x+20,y-100);
curveVertex(x+30,y-45);
curveVertex(x+55,y-15);
curveVertex(x+70,y-50);
curveVertex(x+65,y-60);
endShape(CLOSE);
beginShape();
curveVertex(x+20,y-90);
curveVertex(x+30,y-45);
curveVertex(x+5,y-25);
curveVertex(x,y-40);
curveVertex(x+10,y-66);
curveVertex(x+40,y-80);
endShape(CLOSE);
fill(200,25,25);
ellipse(x+20,y-43,10,10);
ellipse(x+49,y-35,10,10);
fill(255,0,0);
ellipse(x+35,y-40,25,25);
//move the object
x= x+ speed;
y= y+ speed;
//change directions
if (x <= 1 )
{
speed = -speed;
}
else if (y>= 150 )
{
speed = - speed;
}
}
1