I literally don’t get what i should do here. there are no instructions on what variables to use or what guide point i should get. here is my code.
// You are on your own this time, I hope you have learned what you need from the previous fractal levels. Check the guide for help with what you need to do and with the math required for polygons.
hero.setFlowerColor("purple");
// You need a function to convert degrees to radians. Multiply degrees by Math.PI / 180.
function convert(n){
return Math.PI / 180 * n;
}
// Your polygon function should have 3 inputs: start, end, and sides.
function polygon (start,end,sides){
var full = Vector.subtract(end , start);
var mag = full.magnitude();
if (mag < 2) {
hero.toggleFlowers(false);
hero.moveXY(start.x, start.y);
hero.toggleFlowers(true);
hero.moveXY(end.x, end.y);
return;
}
var fifth = Vector.multiply(full, 1/5);
var angle = convert(360/sides);
var A = Vector.add(start ,fifth);
var rotate = Vector.rotate(fifth,angle);
var B = Vector.add(rotate,A);
var C = Vector.add(rotate,B);
var D = Vector.add(rotate,C);
polygon(start,A,sides);
polygon(A,B,sides);
polygon(B,C,sides);
polygon(C,D,sides);
polygon(D,end,sides);
}
// Remember to make your polygon recursive, drawing extra polygons at every corner.
// To get the start and end position for each polygon, add startOffset and endOffset to the yak's position.
var startOffset = new Vector(-15, -15);
var endOffset = new Vector(15, -15);
var enemies = hero.findEnemies();
// You need to loop through all the yaks, drawing a polygon for each. Yaks are enemies.
for (var i = 0; i < enemies.length;i++){
var enemy = enemies[i];
var sides = enemy.sides;
var start = Vector.add(enemy.pos, startOffset);
var end = Vector.add(enemy.pos, endOffset);
polygon(start,end,sides);
}
Note: this code creates a weird shape on the first yak. that’s it
I heard that @Chaboi_3000 has done this level, so i might need to get some tips from him. been trying for days.
ANY help would be appreciated
Riley