penColor("black");
dot(2000);
penUp();
function drawComet(x, y, size, speed) {
penRGB(238, 71, 29, 1);
moveTo(x, y);
penDown();
dot(size);
penUp();
turnTo(45);
moveForward(size);
turnTo(135);
penDown();
moveForward(speed);
penUp();
moveTo(x, y);
turnTo(180);
moveForward(size);
penDown();
turnTo(135);
moveForward(speed);
penUp();
moveTo(x, y);
turnTo(130);
moveForward(size);
penDown();
moveForward(speed);
penUp();
}
drawComet(40, 383, randomNumber(5, 10), randomNumber(20, 40));
drawComet(240, 390, randomNumber(5, 10), randomNumber(20, 40));
function drawAsteroid(x, y) {
penRGB(132, 72, 12, 1);
penWidth(5);
moveTo(x, y);
penDown();
arcRight(90, 2);
arcRight(90, 2);
arcLeft(90, 2);
arcRight(90, 2);
arcRight(90, 2);
arcLeft(90, 2);
arcRight(90, 2);
arcRight(90, 2);
arcLeft(90, 2);
arcRight(90, 2);
arcRight(90, 2);
turnTo(270);
moveForward(5);
turnTo(180);
moveForward(5);
turnTo(90);
moveForward(5);
penUp();
}
for (var i = 0; i < 40; i++) {
drawAsteroid(randomNumber(10, 300), randomNumber(15, 125));
}
No comments:
Post a Comment