-
-
Save shrutis22/1fff5fb7a6b87ba3b278 to your computer and use it in GitHub Desktop.
Collision Detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkCollision() { | |
var yellow = opponentPos[0]; | |
var blue = opponentPos[1]; | |
var green = opponentPos[2]; | |
var opp1Top = parseInt($(".opponent-1").css("top")); | |
var opp2Top = parseInt($(".opponent-2").css("top")); | |
var opp3Top = parseInt($(".opponent-3").css("top")); | |
var playerLeftPos = parseInt($(".player").css("left")); | |
if ( | |
(yellow === playerLeftPos && opp1Top >= 300) || | |
(blue === playerLeftPos && opp2Top >= 300) || | |
(green === playerLeftPos && opp3Top >= 300) | |
) { | |
alert("You have Lost the Game !!"); | |
reset(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment