[Solved] PolygonCeption - Need Help


#1

Hi, I haven’t posted in a while, so this might be a bit shabby and vague.
I need help on this level in the Glacier. I have just started and I don’t really know how to move on from this point. Here is a screenshot with my code:


#2

Can you please post your code? It’s kind of hard to read with a screen shot. Just press the “</>” button and paste your code in the triple black tick marks -------------> ‘’'


#3

Wait, what language is this?


#4

python (20 characters)


#5

Can’t really help you on that, I have also some trouble understanding vector


#6

shoot
can anyone actually help me with my problem?
Also, Rebecca, those aren’t back ticks. I have been on this forum much longer than you have and I know how to do it. Just saying, if you click on the image you can magnify it.

For anyone that is trying to help me, my problem is that it thinks sides is an object.


#7

can you repost your code in raw using </>
I’m going to try to help you.

remember that a vector is a direction from 0, 0.
if you say yak.pos is a vector. and yak position is 40x 70y.
then the vector is a direction of +40x and +70y

if you say that hero.pos is a vector and hero position is 60x and 60y
then the vector is a direction of +60x and +60y.

to know the amount of X and Y the hero must move to reach the yak.position.
then you need to substract the vector yak.position - with the vector hero.position.
the result is - 20x and +10y.

So if your hero move of -20x and 10y. he should reach the yak position.


#8

Oh. Sorry for, um, assuming things. I seriously can’t read code from screenshots though. It’s too small and I’m kind of nearsighted.


#9

I’m nearsighted to, but I’ll type down the code

def  degreesToRadians(degrees):
    degrees * Math.PI / 180

def polygonMaker(start, end, sides):
    full = Vector(start, end)

startOffset = Vector(-15,-15)
endOffset = Vector(15, -15)
yaks = hero.findByType("ice-yak")
for yak in yaks:
    start = Vector.add(yak.pos, startOffset)
    end = Vector.add(yak.pos, endOffset)
    sides = yak.sides

polygonMaker(start, end, 6)

I also accidentally deleted it twice, so it was really, really hard.

The last time I checked, there is no line of code called something.sides, but I could be wrong.


#10

I saw something like that in a different polygonception forum which had been dead for years. Here is the threads link.

Edit: I have some new code to show. I think this will work except for the original error. Here it is

# 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.

# You need a function to convert degrees to radians.  Multiply degrees by Math.PI / 180.
def degreesToRadians(degrees):
    degrees * Math.PI / 180
# Your polygon function should have 3 inputs: start, end, and sides.
def polygonMaker(start, end, sides):
    # Remember to make your polygon recursive, drawing extra polygons at every corner.
    heroShouldStartHere = Vector.subtract(yak.pos, hero.pos)
    full = Vector(start, end)
    for side in sides:
        i = 0
        while i < len(sides):
            nextMovement = Vector.add(start, side)
            i += 1
        i = 0
        break
    
# To get the start and end position for each polygon, add startOffset and endOffset to the yak's position.
startOffset = Vector(-15, -15)
endOffset = Vector(15, -15)
yaks = hero.findByType("ice-yak")
for yak in yaks:
    start = Vector.add(yak.pos, startOffset)
    end = Vector.add(yak.pos, endOffset)
    sides = yak.sides # You need to loop through all the yaks, drawing a polygon for each.  Yaks are enemies.
    polygonMaker(start, end, sides)


#11

oh. sorry (20 chars)