Mountain Flower Grove javascript[solved]

// This level is a place for making flower art.
// The real goal is to experiment and have fun!
// If you draw something with at least 1000 flowers, you will "succeed" at the level.
var pos = [];
pos[1] = {'x': 31, 'y': 106};
pos[2] = {'x': 64, 'y': 105};
pos[3] = {'x': 73, 'y': 100};
pos[3] = {'x': 93, 'y': 101};
pos[4] = {'x': 74, 'y': 61};

hero.drawCircle = function(x, y, size) {
    var angle = 0;
    hero.toggleFlowers(false);
    while (angle <= Math.PI * 2) {
        var newX = x + (size * Math.cos(angle));
        var newY = y + (size * Math.sin(angle));
        hero.moveXY(newX, newY);
        hero.toggleFlowers(true);
        angle += 0.2;
    }
};

while (true) {
    hero.drawCircle(pos, 10);
}

which is type ‘string’ not number
error at this part hero.moveXY(newX, newY);
this is already string.
*string var newX = x + (size * Math.cos(angle)); var newY = y + (size * Math.sin(angle));

You never defined pos

Hint
var pos = hero.pos

in the while true loop

this ?? 20 character

Oh I see the problem now, change the pos in hero.drawCircle(pos,10) to something else like posi so:

while (true){
var posi = hero.pos
hero.drawCircle(posi, 10)
}

wait i want to make the hero move to position like this

i try this maybe works

while (true) {
    for (var i = 0; i < pos.length; i ++) {
        hero.drawCircle(pos[i], 10);
    }
}

// This level is a place for making flower art.
// The real goal is to experiment and have fun!
// If you draw something with at least 1000 flowers, you will "succeed" at the level.
var pos = [];
pos[0] = {'x': 31, 'y': 106};
pos[1] = {'x': 64, 'y': 105};
pos[2] = {'x': 73, 'y': 100};
pos[3] = {'x': 93, 'y': 101};
pos[4] = {'x': 74, 'y': 61};

hero.drawCircle = function(x, y, size) {
    var angle = 0;
    hero.toggleFlowers(false);
    while (angle <= Math.PI * 2) {
        var newX = x + (size * Math.cos(angle));
        var newY = y + (size * Math.sin(angle));
        hero.moveXY(newX, newY);
        hero.toggleFlowers(true);
        angle += 0.2;
    }
};

while (true) {
    for (var i = 0; i < pos.length; i ++) {
        hero.drawCircle(pos[i], 10);
    }
}

here the whole code still dosen’t work

I think this might just be an error you can’t fix because I added var x = hero.pos.x; and var y = hero.pos.y and it gave me this error:
image

is this bug ‘which is type number not number’?

Try using hero.say to debug the code. So after you define every variable try to say what it is and then say the value.

Example:

while (angle <= Math.PI * 2) {
    var newX = x + (size * Math.cos(angle));
    hero.say("The new x variable is: " + newX)

It should help to find the source of the problem

what where should i put it?

after every variable

what variable there many variable here

All of them, you are debugging, so you are trying to find the problem, but you have absolutely no idea where it is, so you have to try everything

ok wiauodwaoiuoisufw

hero say as string not number [objectObject]NaN

So here is the problem, now you know where the problem is and what this variable returns, now try to track it, why is it returning it as an object, how can you make it a number, based on what you already have.

i think the problem is at this part.

look it need x and y pos not just the ‘pos’

Thats some good debugging, i think all you have to do is make it pos[i].x and pos[i].y or something, you can try that

1 Like

it works im using x y and while true loop that make a circle infinite times

1 Like