The geometry of flowers

it keeps on saying that my move xy requires 2 numbers

def drawCircle(x, y, size):
    angle = 0
    hero.toggleFlowers(False)
    while angle <= Math.PI * 2:
        newX = x + (size * Math.cos(angle))
        newY = y + (size * Math.sin(angle))
        hero.moveXY(newX, newY)
        hero.toggleFlowers(True)
        angle += 0.2

Hi, could you also post the rest of your code, please.
Thanks

1 Like
def drawCircle(x, y, size):
    angle = 0
    hero.toggleFlowers(False)
    while angle <= Math.PI * 2:
        newX = x + (size * Math.cos(angle))
        newY = y + (size * Math.sin(angle))
        hero.moveXY(newX, newY)
        hero.toggleFlowers(True)
        angle += 0.2

def drawSquare(x, y, size):
    hero.toggleFlowers(False)
    cornerOffset = size / 2
    hero.moveXY(x - cornerOffset, y - cornerOffset)
    hero.toggleFlowers(True)
    hero.moveXY(x + cornerOffset, y - cornerOffset)
    hero.moveXY(x + cornerOffset, y + cornerOffset)
    hero.moveXY(x - cornerOffset, y + cornerOffset)
    hero.moveXY(x - cornerOffset, y - cornerOffset)


redX = {"x": 28, "y": 36}
whiteX = {"x": 44, "y": 36}

# Pick a color.
hero.setFlowerColor("red")
# Draw a size 10 circle at the redX.
def drawCircle(x, y, size):
    angle = 0
    hero.toggleFlowers(False)
    while angle <= Math.PI * 2:
        newX = x + (size * Math.cos(angle))
        newY = y + (size * Math.sin(angle))
        hero.moveXY(newX, newY)
        hero.toggleFlowers(True)
        angle += 0.2
drawCircle()
# Change the color!
hero.setFlowerColor("blue")
# Draw a size 10 square at the whiteX.
hero.moveXY(39, 44)
hero.moveXY(49, 44)
hero.moveXY(49, 34)
hero.moveXY(39, 34)
# Now experiment with drawing whatever you want!
hero.moveXY(56, 35)
sry

You need to put inputs into the brackets of the function, otherwise there aren’t any inputs.

1 Like

what do you mean by inputs?

Things which go into the function.
e.g. findEnemy(enemies)
enemies is the input.

ok i’ll try that(20chararcters)

it did not work

I think you should maybe review older function levels because you don’t seem to understand them.
Let me try to explain:
The function drawCircle(x, y, size) has three inputs: x, y, and size. That means you need to put three values in, otherwise your code sill have nowhere to move to because when you define NewX and NewY it uses the variables which you put in the brackets of the function. Therefore because you haven’t put any in, it doesn’t work. Hence the error.
Try putting three variables in the function. The X, Y, and the Size. You’ve only put in the size.
To give you a hint I’ll show you what a three input function might look like with inputs:

# first you define it
def drawSquare(x, y, size):
    # code goes here....
    pass

# then call (use) the function
drawSquare(30, 46, 10)

Remember! “The order you put the values in the brackets of the function matters, you couldn’t do the size first, then the x and y. Unless you changed it when you defined it.”
Do you get it more now?

1 Like

thank you I re-read what you said three times and I understood