Question: inside the checkCollision() function i have to loop over the two objects since they are movable object to know if they are colliding or not

inside the checkCollision() function i have to loop over the two objects since they are movable object to know if they are colliding or not so if they are intersecting the gane will over esle the game still working normal. So please it is not working when i am looping to.check if the spaceShip intersect with the astroids the game should over

example: checkCollision() { for(var i =0; i < asteriods.length;i++) { if(isInside(spaceShip.locA, spaceShip.sizeA, astroids[i].locB, astroids[i].sizeB)) { gameOver(); } } }

but the checkCollision function is not working maybe i didn't put the parameters properly please assist

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!