Cannon read property "read" of undefined in Polygonception


#1

I tried solving “Polygonception” from the Glacier using the technique shown in previous levels, but for some reason I keep getting the error above.

Here’s what I’m doing:

startOffset = Vector(-15, -15)
endOffset = Vector(15, -15)
enemies = self.findEnemies()
for enemy in enemies:
    start = Vector.add(enemy.pos, startOffset) 
    end = Vector.add(enemy.pos, endOffset)
    sides = enemy.sides
    polygon(start, end, sides)

where polygon is defined as follows:

def polygon(start, end, side):
    full = Vector.subtract(end, start)
......................

At the very first line of polygon the error appers. What am I doing wrong?


#2

I’m curious if you got past this because I am having the same problem. I believe I am passing valid vectors to the drawPolygon function, but inside the function it is treating them as undefined. My code looks very similar to yours.


[Solved] PolygonCeption - Need Help
#3

There is a known bug in the python parser, this may cause the problem. The workaround is the following:

def polygon(start_, end_, side):
    start = start_
    end = end_
    full = Vector.subtract(end, start)
    # continue your code here

#4

That fixed it. Thanks so much!