Sniperninja564 Sniperninja564 - 2 months ago 11
Javascript Question

A collision function is not allowing my missile to move

Inside the "drawMissile()" function I make it so it moves the missile's y position 5 pixels each frame! But there is also another function being called: "missileCollision()"

Inside the "missileCollision()" function it checks if it is touching the bowl, if it is, then it will give you a point and reset the position! But if the missile misses the bowl and goes to the bottom of the screen, then you lose a life!

Here is the problem, when it calls the "missileCollision()" function, it won't move down 5 pixels! I tried taking out the "missileCollision()" function, it worked as it should! Why does calling the "missileCollision()" function stops my missile from moving?

I had also tried removing the "missileCollision()" function entirely and just cut and pasted the code into the "drawMissile" function but that didn't work :(

-Thanks in advance!


I haven't check all the code but this line (86) looks bad:

if (missileY = playerY-missileYThick ..

You're doing an assignment here. Use === (instead of =) to compare two variables of the same type.