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

UFO Animation

Piano
Linkbot Image Mindstorm Image
0x2418126y2418126
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

0
S
M
L
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (0 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in

Robot 2

0
S
M
L
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (6 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in

Robot 3

0
S
M
L
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (12 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in

Robot 4

0
S
M
L
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (18 in, 0 in)
Current Angle: 90 deg
Wheel Radius:
Track Width:
in
UFO Animation
/* Code generated by RoboBlockly v2.5 */
#include <chplot.h>
CPlot plot;
double Number_of_UFOs;
double Y_Pos;
double Xpos;
double x;
double y;

Number_of_UFOs = 5;
for(Y_Pos = 1.5; Y_Pos <= 22; Y_Pos++) {
  //plot.backgroundImage("stars.png");
  double Xpos_end = Number_of_UFOs * 5;
  double Xpos_inc = 5;
  if (2 > Xpos_end) {
    Xpos_inc = -Xpos_inc;
  }
  Xpos = 2;
  while(Xpos_inc >= 0 ? Xpos <= Xpos_end : Xpos >= Xpos_end) {
    x = Xpos;
    y = Y_Pos;
    plot.strokeColor("black");
    plot.fillColor("#ffff66");
    plot.circle(x, y, 1);
    plot.fillColor("#cccccc");
    plot.ellipse(x, y - 0.5, 1.6, 1, 0);
    plot.ellipse(x, y - 0.2, 3, 1, 0);
    plot.fillColor("#ffff66");
    plot.strokeColor("#ffff66");
    plot.ellipse(x, y + 0.2, 1.9, 0.6, 0);
    plot.strokeWidth(1.2);
    plot.strokeColor("black");
    plot.ellipseArc(x, y + 0.2, 2, 0.65, 0, 0, -180);
    plot.fillColor("#33ff33");
    plot.circle(x - 1, y - 0.2, 0.1);
    plot.circle(x + 1, y - 0.2, 0.1);
    plot.circle(x, y - 0.4, 0.1);
    Xpos += Xpos_inc;
  }
  delaySeconds(0.05);
}

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, 24);
plot.ticsRange(PLOT_AXIS_XY, 2);
plot.sizeRatio(1);
plot.plotting();
Load Blocks
Hardware
LArduino
Workspace Show Ch Save File
Problem Statement:

Change the value of UFOs flying through the grid, and understand how the code works.


		
Rubbish bin
Time