A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 2 years ago
Need help on this code, but I got this so much far;
float bX = 50;
float bY = 60;
float bWidth = 55;
float bHeight = 70;
color balloonColor = color(255, 0, 0);
float bHSpeed = 2;
float bVSpeed = 1;
void setup()
{
size(300, 300);
bWidth = random(10, 55);
bHeight = random(10, 70);
balloonColor = color(random(0, 255), random(0, 255), random(0, 255)); // randomly set the balloon color
ellipse(bX + 50, bY + 60, bWidth + 55, bHeight + 70); // 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( )
{
background(255);
drawHouse(150, 200, 80, 80);
drawHouse(20, 100, 120, 150);
drawBalloon(bX, bY, bWidth, bHeight, balloonColor);// draw the balloon by calling drawBalloon()
// if there is a horizontal bounce, reverse horizontal speed
// if there is a vertical bounce, reverse vertical speed
}
/*
Your code for drawBalloon( ) goes here
*/
void drawBalloon(float x, float y, float w, float h, color c)
{
fill(c);
ellipse(x, y, w, h);
}
/*
Your code for drawHouse( ) goes here
*/
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);
}
 2 years ago
Need help on this code, but I got this so much far; float bX = 50; float bY = 60; float bWidth = 55; float bHeight = 70; color balloonColor = color(255, 0, 0); float bHSpeed = 2; float bVSpeed = 1; void setup() { size(300, 300); bWidth = random(10, 55); bHeight = random(10, 70); balloonColor = color(random(0, 255), random(0, 255), random(0, 255)); // randomly set the balloon color ellipse(bX + 50, bY + 60, bWidth + 55, bHeight + 70); // 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( ) { background(255); drawHouse(150, 200, 80, 80); drawHouse(20, 100, 120, 150); drawBalloon(bX, bY, bWidth, bHeight, balloonColor);// draw the balloon by calling drawBalloon() // if there is a horizontal bounce, reverse horizontal speed // if there is a vertical bounce, reverse vertical speed } /* Your code for drawBalloon( ) goes here */ void drawBalloon(float x, float y, float w, float h, color c) { fill(c); ellipse(x, y, w, h); } /* Your code for drawHouse( ) goes here */ 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); }

This Question is Closed

pdpinch
 2 years ago
Best ResponseYou've already chosen the best response.0This doesn't look like Python. You might have better luck posting this in the 6.00 group.

rsmith6559
 2 years ago
Best ResponseYou've already chosen the best response.0When in doubt, decompose it ( break it down ) more. Both of the draw functions need the coordinates to start at, and size and color information to draw a static image. Any movement would be done by other function[s].

rohitranjan1994
 2 years ago
Best ResponseYou've already chosen the best response.0which programing language you are using
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.