U3L8 - Bubble 12

I’ve spent hours on this code with a student (and on my own). Error says it’s at line 72 “parameter value for r, g, b” undefined.

I’m very new to this and need more help - I basically understand that line 72 doesn’t understand what the r,g,b values are – but I thought they were declared on line 24.

Thank you!

// Prepare Turtle to Draw
hide();
penUp();

// First draw the background
drawBackground();

moveTo(150,400);
// draw all the starfish
drawStarfish(randomNumber(20, 60));
moveTo(200,350);
drawStarfish(randomNumber(30, 50));
// Draw all the seagrass on bottom of screen
moveTo(50,450);
turnTo(0);
drawSeagrass(50,90);
moveTo(75,450);
drawSeagrass(70,110);
// Draw all the fish
moveTo(100,100);
drawFish(randomNumber(1, 20));
moveTo(200,200);
drawFish(randomNumber(1, 50), randomNumber(255), 0, randomNumber(200));

// Make the background by drawing a large dot
function drawBackground(){
penColor(“DarkBlue”);
dot(1000);
}

// Draw a five pointed star with a wide pen.
function drawStarfish(size){
// Setting up the pen
penRGB(255,0,255);
penWidth(20);
penDown();

turnTo(0);
moveForward(size);
turnRight(144);
moveForward(size);
turnRight(144);
moveForward(size);
turnRight(144);
moveForward(size);
turnRight(144);
moveForward(size);
turnRight(144);
penUp();
}

// Switches between left and right arcs to make sea grass
function drawSeagrass(radiusSize){
// Setting up the pen
penRGB(0,255,0);
penWidth(10);
penDown();

// Draw four arcs to make grass
arcLeft(radiusSize,radiusSize);
arcRight(radiusSize,radiusSize);
arcLeft(radiusSize,radiusSize);
arcRight(radiusSize,radiusSize);

penUp();
}

// Draw a single fish at current turtle location
function drawFish(size, red, green, blue){
// Setting up the pen
penRGB(red, green, blue);
penWidth(size);
penDown();

// Fish body
dot(size);
turnTo(90);
moveForward(size);

// Fish tail
turnLeft(30);
moveForward(size);
turnRight(120);
moveForward(size);
turnRight(120);
moveForward(size);
turnRight(120);

penUp();
}

Hi -

The problem is at line 21 :
drawFish(randomNumber(1, 20));

The drawFish function requires 4 parameters but only 1 argument is being passed to the function.
Try : drawFish(randomNumber(1, 20), 100,100,100);

  • Mitch
2 Likes

Tell me what you are trying to accomplish. For now, this solution will not change the pen color if it is not specified.