Created
July 26, 2017 08:06
-
-
Save LtAstros/c766fea208b7f7cba7c41981ddaa0a4b to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=c766fea208b7f7cba7c41981ddaa0a4b
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<div id="blop1" class="blops"></div> | |
<div id="blop2" class="blops"></div> | |
<div id="blop3" class="blops"></div> | |
<div id="blop4" class="blops"></div> | |
<div id="blop5" class="blops"></div> | |
<div id="blop6" class="blops"></div> | |
<div id="blop7" class="blops"></div> | |
<div id="blop8" class="blops"></div> | |
<div id="blop9" class="blops"></div> | |
<div id="blop10" class="blops"></div> | |
<div id="char"></div> | |
</body> | |
</html> |
This file contains hidden or 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
{"enabledLibraries":["jquery"]} |
This file contains hidden or 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
var random = (Math.floor((Math.random() * 100) + 1)) + "%"; | |
var score = 0; | |
setInterval(function(){ | |
for(var count = 1; count < 11; count = count + 1){ | |
var charTop = $("#char").offset().top; | |
var charLeft = $("#char").offset().left; | |
var charRight = charLeft + $("#char").width(); | |
var blopsBot = $("#blop"+count).offset().top + $("#blop"+count).height; | |
var blopsLeft = $("#blop"+count).offset().left; | |
var blopsRight = $("#blop"+count).offset().left + 20; | |
$("#blop"+count).css("top", $("#blop"+count).offset().top + 1); | |
if (blopsBot > charTop+70) { | |
$("#blop"+count).css('top', 0); | |
$("#blop"+count).css('left', Math.floor(Math.random() * 580)); | |
} | |
else if (blopsBot > charTop && (blopsLeft >= charLeft && blopsRight <= charRight)) { | |
$("#blop"+count).css('top',0); | |
$("#blop"+count).css('left', Math.floor(Math.random() * 580)); | |
score += 1; | |
} | |
} | |
},1); | |
for(var count = 1; count < 11; count = count + 1){ | |
$("#blop"+count).css("top", -125 * count); | |
$("#blop"+count).css("left",Math.floor(Math.random() * 580)); | |
} | |
$("body").keydown(function(event) { | |
if (event.which === 37) { | |
$("#char").css("left", $("#char").offset().left - 15); | |
} else if (event.which === 39) { | |
$("#char").css("left", $("#char").offset().left + 15); | |
} else { | |
return; | |
} | |
}); | |
This file contains hidden or 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
.blops { | |
width: 20px; | |
height: 20px; | |
background-color: salmon; | |
position: absolute; | |
} | |
#char { | |
width: 50px; | |
height: 50px; | |
background-color: yellow; | |
position: absolute; | |
top: 85%; | |
left: 50%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment