PLZ Give me the solutuion for the level called Zone of Danger


#1

Please please pleasePLZ Give me the solutuion for the level called Zone of Danger


#2

Before I post any solutions, maybe I can guide you through it.

Do you think you have the distanceTo function right? Do you know how to calculate a distance? http://en.wikipedia.org/wiki/Distance#Mathematics might help here.

About getNearestEnemy, did you check out the for loop snippet? It is a good idea make an array of enenmies. Then, it’s a good idea to use a for loop. In each iteration of the for loop you consider one enemy, so that the iterator runs from 0 to enemies.length - 1. At every iteration, you check to see if the distance to the enemy currently being considered is smaller than that of all the enemies considered so far. If the distance is smaller, the enemy being considered should be the new target.

Does that help?


#3

Not really. Can u just give me solution


#5

Still Dosen’t work. Help me. My multiplayer link is:


I beg u 2 help me.


#6

I have edited your code. Now it works. You put both the code blocks above (along with their descriptions) into the function getNearestEnemy(). You were supposed to copy paste the block under getNearestEnemy into getNearestEnemy and the block under distanceTo into distanceTo.

I do encourage you to write your own solution. Maybe you can come up with your own version of distanceTo?


#7

Can you please help me with Gridmancer Then???


#8

I have not solved gridmaster myself. But wouldn’t it be fun for you to play around with the code I gave you? Or maybe try an easier level?


#9

@jacobakkerboom we don’t post correct code


#10

@jtonuri do not ask for correct code.


#11

@Neel_Sharma Please report such posts in the future. Click in the “Flag” icon below a post and it will open an interface to report the post to the staff.


#12

I did flag the posts. Then I wrote these posts.


#13

Oh I see, your flag was handled by another moderator.
I’ve deleted the post as it was nothing but an attempt to provide a solution that is not useful to future readers at all.


#14

Yeah ok thanks Ultcombo