function part1
in
Programming Questions
•
11 months ago
I can't figure how to get the string which is suppose to be line for the balloon. Here how it looks like;
http://imgur.com/jjhZJ
float bX = 50;
float bY = 60;
float bWidth = 70;
float bHeight = 80;
color balloonColor = color(0, 0, 255);
float bHSpeed = 2;
float bVSpeed = 2;
void setup()
{
size(300, 300);
bWidth = random(10, 70);
bHeight = random(10, 80);
balloonColor = color(random(0, 255), random(0, 255), random(0, 255)); // randomly set the balloon color
ellipse(bX + 50, bY + 60, bWidth + 70, bHeight + 80); // set bX and bY; make sure that the balloon
//will be entirely on screen when it starts
bX = random(bWidth / 2.0, width - bWidth / 2.0);
bHSpeed = 2;
bVSpeed = 2;
smooth();
}
void draw( )
{
bX += bHSpeed;
bY += bVSpeed;
background(255);
drawHouse(20, 155, 95, 95);
drawHouse(150, 80, 120, 170);
drawBalloon(bX, bY, bWidth, bHeight, balloonColor);// draw the balloon by calling drawBalloon()
bX += bHSpeed;
if (bX < bWidth / 2 || bX > width - bWidth / 2)
{
bHSpeed = -bHSpeed;
}
if (bY < bHeight / 2 || bY > width - bHeight / 2)
{
bVSpeed = -bVSpeed;
}
}
void drawBalloon(float x, float y, float w, float h, color c)
{
fill(c, 50);
ellipse(x, y, w, h);
fill(10, 30, 110, 20);
}
void drawHouse(float x, float y, float w, float h)
{
float topY = y + h / 3.0;
fill(255);
stroke(0);
triangle(x + w / 2.0, y, x, topY, x + w, topY);
rect(x, topY, w, 2.0 * h / 3.0);
rect(x + w / 8.0, y + h / 3.0 + (0.125) * 2 * h / 3.0, w / 8.0, h / 8.0);
rect(x + 5.0 / 8.0 * w, y + 3.0 / 4.0 * h, 3.0 / 16.0 * w, h / 4.0);
}
http://imgur.com/jjhZJ
float bX = 50;
float bY = 60;
float bWidth = 70;
float bHeight = 80;
color balloonColor = color(0, 0, 255);
float bHSpeed = 2;
float bVSpeed = 2;
void setup()
{
size(300, 300);
bWidth = random(10, 70);
bHeight = random(10, 80);
balloonColor = color(random(0, 255), random(0, 255), random(0, 255)); // randomly set the balloon color
ellipse(bX + 50, bY + 60, bWidth + 70, bHeight + 80); // set bX and bY; make sure that the balloon
//will be entirely on screen when it starts
bX = random(bWidth / 2.0, width - bWidth / 2.0);
bHSpeed = 2;
bVSpeed = 2;
smooth();
}
void draw( )
{
bX += bHSpeed;
bY += bVSpeed;
background(255);
drawHouse(20, 155, 95, 95);
drawHouse(150, 80, 120, 170);
drawBalloon(bX, bY, bWidth, bHeight, balloonColor);// draw the balloon by calling drawBalloon()
bX += bHSpeed;
if (bX < bWidth / 2 || bX > width - bWidth / 2)
{
bHSpeed = -bHSpeed;
}
if (bY < bHeight / 2 || bY > width - bHeight / 2)
{
bVSpeed = -bVSpeed;
}
}
void drawBalloon(float x, float y, float w, float h, color c)
{
fill(c, 50);
ellipse(x, y, w, h);
fill(10, 30, 110, 20);
}
void drawHouse(float x, float y, float w, float h)
{
float topY = y + h / 3.0;
fill(255);
stroke(0);
triangle(x + w / 2.0, y, x, topY, x + w, topY);
rect(x, topY, w, 2.0 * h / 3.0);
rect(x + w / 8.0, y + h / 3.0 + (0.125) * 2 * h / 3.0, w / 8.0, h / 8.0);
rect(x + 5.0 / 8.0 * w, y + 3.0 / 4.0 * h, 3.0 / 16.0 * w, h / 4.0);
}
1