Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- $('audio').trigger('play');
- debounce = false;
- ra = true;
- setInterval(function() {
- $('.obstacles').css('border-color', 'rgb(0, ' + (Math.floor(Math.random(180, 255)*200 /*end floor*/)).toString() + ', ' + (Math.floor(Math.random(200, 255)*200 /*end floor*/)).toString() + ')')
- }, 1000);
- $(document).keypress(function(evt) {
- //start touch trigger--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- if ($('#div').offset().left > ($('#block2').offset().left - 110) && $('#div').offset().left < ($('#block2').offset().left + 130) && $('#div').offset().top > ($('#block2').offset().top - 110) && $('#div').offset().top < ($('#block2').offset().top + 130)) {
- $('#div').offset({top: 0, left: 0})
- };
- if ($('#div').offset().left > ($('#block4').offset().left - 110) && $('#div').offset().left < ($('#block4').offset().left + 130) && $('#div').offset().top > ($('#block4').offset().top - 110) && $('#div').offset().top < ($('#block4').offset().top + 130)) {
- $('#div').offset({top: 0, left: 0})
- };
- if ($('#div').offset().left > ($('#block3').offset().left - 110) && $('#div').offset().left < ($('#block3').offset().left + 130) && $('#div').offset().top > ($('#block3').offset().top - 110) && $('#div').offset().top < ($('#block3').offset().top + 130)) {
- $('#div').offset({top: 0, left: 0})
- };
- if ($('#div').offset().left > ($('#block').offset().left - 110) && $('#div').offset().left < ($('#block').offset().left + 130) && $('#div').offset().top > ($('#block').offset().top - 110) && $('#div').offset().top < ($('#block').offset().top + 130)) {
- $('#div').offset({top: 0, left: 0})
- };
- if ($('#div').offset().left > ($('#block6').offset().left - 110) && $('#div').offset().left < ($('#block6').offset().left + 130) && $('#div').offset().top > ($('#block6').offset().top - 110) && $('#div').offset().top < ($('#block6').offset().top + 130)) {
- $('#div').offset({top: 0, left: 0})
- };
- setInterval(function() {
- if ($('#div').offset().left > ($('#block5').offset().left - 110) && $('#div').offset().left < ($('#block5').offset().left + 130) && $('#div').offset().top > ($('#block5').offset().top - 110) && $('#div').offset().top < ($('#block5').offset().top + 130)) {
- $('#div').offset({top: 0, left: 0})
- };
- }, 1000);
- //end touch trigger and start key trigger--------------------------------------------------------------------------------------------------------------------------------------------------------
- if (String.fromCharCode(evt.which) == "d") {
- $("#div").animate({
- left: "+=10"
- }, 20);
- //start thing
- };
- if (String.fromCharCode(evt.which) == "a" && $('#div').offset().left > 0){
- $("#div").animate({
- left: "-=10"
- }, 20);
- };
- if ($('#div').offset().left < 0 ){
- $('#div').animate({
- left: '0'
- }, 'swing').stop()
- };
- if (String.fromCharCode(evt.which) == "s" && $('#div').offset().top < 820) {
- $("#div").animate({
- top: "+=10"
- }, 10);
- };
- if (String.fromCharCode(evt.which) == "w") {
- $("#div").animate({
- top: "-=10"
- }, 10);
- };
- if (String.fromCharCode(evt.which) == "g" && prompt('enter the password to get acess to this content', 'the password ISNT edmodoRocks').toString() == 'edmodoRocks') {
- alert('left coordinates: ' + $('#div').offset().left + ', top coordinates: ' + $('#div').offset().top)
- };
- if (String.fromCharCode(evt.which) == " ") {
- $("#div").animate({
- top: "-=100"
- }, 400).animate({
- top: "+=100"
- }, 400);
- };
- if (debounce == false) {
- $("h3").slideUp(2000);
- debounce = true;
- };
- //end key trigger------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- });
- $("#div").dblclick(function() {
- $("#div").animate({
- top: "-=300",
- left: "+=400"
- }, 2000).animate({
- top: "+=300"
- }, 500);
- });
- //moving obstacles---------------------------------------------------------------------------------------------------------------------------------------------------------------------
- ///start
- setInterval(function() {
- $('#block5').animate({
- left: '+=200',
- top: '-=200'
- }, 1500);
- setTimeout(function() {
- $('#block5').animate({
- left: '-=200',
- top: '+=200'
- }, 1500);
- }, 2000);
- }, 2000);
- //end
- });
- /*end jquery script......*/
- </script>
- </head>
- <body>
- <h2 stye = "text-align: center;">Welcome to my game!</h2>
- <h3>click any button to start</h3>
- <h5>use the w, s, a, d, and space keys to operate your character</h5>
- <h2><strong>don't</strong> hit the blocks!</h2>
- <div id = "div" style="height:100px;width:100px;position:absolute;">
- <img src = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS3YFILtpAEZ3mdhMl-N-EU0jFna90Hbpu_lpS23idcSaVgjWSF" style = "height: 100px; width: 100px;border-radius: 0px;" /></div>
- <!--obstacles-->
- <div class = 'obstacles' id = "block2" style="height:100px;width:100px;position:absolute;background: #FF6666; top: 300px; left: 250px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block" style="height:100px;width:100px;position:absolute;background: #FF6666; top: 100px; left: 400px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block3" style="height:100px;width:100px;position:absolute;background: #FF6666; top: 600px; left: 450px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block4" style="height:100px;width:100px;position:absolute;background: #ff6666; top: 800px; left: 150px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block6" style="height:100px;width:100px;position:absolute;background: #ff6666; top: 710px; left: 200px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block5" style="height:100px;width:100px;position:absolute;background: #ff6666; top: 700px; left: 500px;border: 10px solid blue">
- </div>
- <audio>
- <source src="file:///C:/Users/user/Downloads/KDrew%20-%20Bullseye.mp3" type="audio/mp3">
- </audio>
- <span id = 'coords'>
- </span>
- </body>
- </html>
- class = 'obstacles' id = "block" style="height:100px;width:100px;position:absolute;background: #FF6666; top: 100px; left: 400px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block3" style="height:100px;width:100px;position:absolute;background: #FF6666; top: 600px; left: 450px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block4" style="height:100px;width:100px;position:absolute;background: #ff6666; top: 800px; left: 150px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block6" style="height:100px;width:100px;position:absolute;background: #ff6666; top: 710px; left: 200px;border: 10px solid blue">
- </div>
- <div class = 'obstacles' id = "block5" style="height:100px;width:100px;position:absolute;background: #ff6666; top: 700px; left: 500px;border: 10px solid blue">
- </div>
- <audio>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement