Problem with infinite loop on sarven treasure 6

@iLuvCookies and @Lydia_Song I will post my code asap but I need to finish homework and laundry
also thanks for coming!also @Lydia_Song I have subscribed to your channel

1 Like

wait @Lydia_Song has a YT if u tell me what it is i’ll check it out.

@098765432123 here is my code

Edited in order to avoid copying. Sincerely yours, Alexbrand.
1 Like

one thing i notice (thats not a problem with the code) but you use self then switch to hero why do you do that? (im at church i’ll help when im done if i can)

what i mean is why do you use self. then switch back to hero. don’t you normally use hero. and not self?

also I reset so I can not access the level

[SOLVED] The game dose not let me in a level it just infinitely load?

I tested the code as described here:How to test code and give help?
image
with this user:
image
the result is:
sarven-tresure-f
Congratulation! Hats down!!! :+1:
The problem isn’t the code
If you do not want to be copied countless times, delete the entire post.

2 Likes

Personally me use both self and hero)

1 Like

thanks it worked(20chars)

You can define teleports as vectors and just use

teleport = hero.findNearest(teleports)

It seems to me the way Riticmaster finds the nearest portal is more efficient - with too many calculations the browser crashes

Well that makes sense.

Uhm, wait a sec.
I meant smth like this:

    t2 = Vector(77,50)
    t3 = Vector(5,50)
    t4 = Vector(77,19)
    t6 = Vector(5,19)
    teleports =[t2, t3, t4, t6]
    teleport = hero.findNearest(teleports)

Does it need many calculations?

hero.findNearest(teleports) is a loop between hero and some points finding distances between them
and sqrt is computational hungry

def calcDistance(x1,y1,x2,y2):  
     dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)  
     return dist
1 Like

Oh, I see. Thank you very much for clarifying.

It is in my profile (click on my profile picture)
And thanks @riticmaster9087!
Lydia

1 Like

its 6 as the title says

I know, he edited it after I said that.


Lydia

1 Like

oh ok(20charssssssss)