Barobo
PortalSign In
HomeShopTutorialsFree CurriculumHour of Code
RoboBlockly for Learning Math and Coding

CSP Unit 3 Lesson 8.10

Piano
Linkbot Image Mindstorm Image Cursor Image
0x36302418126y36302418126
Grid:
Tics Lines:
Width px
Hash Lines:
Width px
Labels:
Font px
Trace Lines:
Robot 1:
Width px
Robot 2:
Width px
Robot 3:
Width px
Robot 4:
Width px
Labels: x-axis y-axis Show Grid
Grid: 12x12 inches 24x24 inches 36x36 inches
72x72 inches 96x96 inches 192x192 inches
Quad: 4 Quadrants 1 Quadrant 1&4 Quadrants
Units: US Customary Metric
Background: Background Image

Robot 1

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (0 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in

Robot 2

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (6 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in

Robot 3

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (12 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in

Robot 4

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (18 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in
CSP Unit 3 Lesson 8.10
/* Code generated by RoboBlockly v2.5 */
/* Problem Statement: 
    The pre-placed code defines several functions (drawFish,
    drawStar, and drawGrass). Scroll down and examine the code
    to get a feel for it, and run it to see what it does. Then
    add a function call to draw another fish at the point x =
    24, y = 30, and add function calls to the drawStar and
    drawGrass functions before running it again. When done, set
    the grid to "off" for the final display. Save your work
    using the filename "YourName_Lesson8.10" (instructions
    above).
    */
#include <chplot.h>
CPlot plot;

// Describe this function...
void drawFish(double fish_x, double fish_y) {
  // Draw a gold fish at the point  (fish_x,fish_y)
  plot.noStrokeColor();
  plot.fillColor("#ffcc66");
  // Body of fish
  plot.ellipse(fish_x, fish_y, 8, 3, 0);
  // Tail of fish
  plot.triangle(fish_x - 5, fish_y + 2, fish_x - 5, fish_y - 2, fish_x - 3, fish_y);
}

// Describe this function...
void drawStar() {
  // Draw an orange star at the point (27, 10)
  plot.noStrokeColor();
  plot.fillColor("#ff6600");
  plot.star(27, 10, 4, 0);
}

// Describe this function...
void drawGrass() {
  // Draw some wavy grass growing at the point (5, 5)
  plot.strokeColor("#33ff33");
  plot.strokeWidth(1);
  plot.arc(5, 5, 1, 270, 90);
  plot.arc(5, 7, 1, 90, 270);
  plot.arc(5, 9, 1, 270, 90);
  plot.arc(5, 11, 1, 90, 270);
}

// Program that draws an underwater scene
// Set underwater background, turn off grid display
//plot.backgroundImage("underwater.png");
// Turn on grid for convenience while working on code
// (When done, set grid "off" for final display)
plot.grid(PLOT_OFF);
// Draw fish at the points (10, 25) and (24, 30)
drawFish(10, 25);
drawFish(24, 30);
// Draw a star and some wavy grass
drawStar();
drawGrass();

plot.label(PLOT_AXIS_XY, "");
plot.grid(PLOT_OFF);
plot.tics(PLOT_AXIS_XY, PLOT_OFF);
plot.axis(PLOT_AXIS_XY, PLOT_OFF);
plot.axisRange(PLOT_AXIS_XY, 0, 36);
plot.ticsRange(PLOT_AXIS_XY, 6);
plot.sizeRatio(1);
plot.plotting();
Load Blocks
Hardware
LArduino
Workspace Show Ch Save File
Problem Statement:

The pre-placed code defines several functions (drawFish, drawStar, and drawGrass). Scroll down and examine the code to get a feel for it, and run it to see what it does. Then add a function call to draw another fish at the point x = 24, y = 30, and add function calls to the drawStar and drawGrass functions before running it again. When done, set the grid to "off" for the final display. Save your work using the filename "YourName_Lesson8.10" (instructions above).


		
Rubbish bin
Time