Snowflakes on the Ice C++ Help!

I don’t know what i’m doing wrong. I’ve looked over my code multiple times and I don’t see why it just makes a straight line. I’ve tried removing and adding a bunch of random stuff to see if it works, but nothing worked. Here’s my code.

// For this level we need to a line fractal for the ground and a hexagonal snowflake made up of 6 line fractals. Check the guide for an image of the desired output.

auto degreesToRadians(auto degrees) {
    // All vector operations require working in radians rather than degrees.
    return Math.PI / 180 * degrees;

// This function creates a line fractal.  Read through it so you understand the recursive concept.
auto line(auto start, auto end) {
    // First we need to get the full vector and its magnitude to determine if we are below our minimum threshold.
    auto full = Vector.subtract(end, start);
    float distance = full.magnitude();
    if (distance < 4) {
        // If under our threshold distance, then we will simply draw a line along the vector and be done (the return tells us to exit the function).
        hero.moveXY(start.x, start.y);
        hero.moveXY(end.x, end.y);
    // Otherwise we will create our fractal by getting a vector of half magnitude.
    auto half = Vector.divide(full, 2);
    // We will be creating 4 line fractals (start -> A, A -> B, B -> A, and A -> end) and so we need to calculate the intermediate positions A and B.
    auto A = Vector.add(half, start);
    // To get B, we need to rotate the vector half 90 degrees and multiply by 2/3 (so it is 1/3 of the original magnitude), then add this to A.
    auto rotate = Vector.rotate(half, degreesToRadians(90));
    rotate = Vector.multiply(rotate, 2 / 3);
    auto B = Vector.add(rotate, A);

    // Now just draw the 4 lines using the line functions.
    line(start, A);
    line(A, B);
    line(B, A);
    line(A, end);

auto flake (auto start, auto end) {
    // To create a hexagonal flake we need to create 6 line fractals rotated by 60 degrees each time.
    auto side = Vector.subtract(end, start);
    auto a = start;
    auto b = end;
    for (int i = 0; i < 6; ++i) {
        line(a, b);
        // To get the next edge, we need to rotate the side 60 degrees.
side = Vector.rotate(side, Math.PI / 3);
        // Now need to reset a and b with the beginning and end points for the new side.
        a = b;
        b = Vector.add(b, side);

int main() {
    auto whiteXs = {*new Vector(12, 10), *new Vector(60, 10)};
    auto redXs = {*new Vector(64, 52), *new Vector(52, 52)};
    // You need to actually call the functions with a start and end vector for each.
    // Be sure to use actual Vector objects–simple objects will not work.
    // Refresh often to avoid a memory leak and crash (working on it)
    return 0;

This is what happens with the code:

Hi @32384! Welcome to the CodeCombat Discourse! This is a safe place to chat and ask for level help. Before you begin your journey, could you please go through our rules that make this discourse an awesome place? It helps us all :grin: We hope you enjoy your stay!!

Also I haven’t done this level yet so I can’t help you so I just welcomed you

Would you perhaps know anyone who has done this level?

Me! :grin:
I beat it in JavaScript, but I’m sure I can help.

1 Like

So do you know what is wrong with my code?