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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Progress Bar</title> | |
<style> | |
.progressBar { | |
width: 75%; |
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
// stick değişkenleri | |
var stickLeft = document.getElementById('stickLeft'); | |
var stickRight = document.getElementById('stickRight'); | |
// ball değişkenleri | |
var ball = document.getElementById('ball'); | |
// puan değişkenleri | |
var scoreLeft = 0; | |
var scoreRight = 0; |
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 gameLoop... | |
if(parseInt(ball.style.left) <= 0){ | |
if(++scoreRight === 5){ | |
alert('2. oyuncu kazandı.'); | |
scoreRight = 0; | |
scoreLeft = 0; | |
document.getElementById('scoreLeft').innerHTML = scoreLeft; | |
} | |
document.getElementById('scoreRight').innerHTML = scoreRight; | |
gameChain(); |
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 gameChain(){ | |
ball.style.top = window.innerHeight/2 + 'px'; | |
ball.style.left = (window.innerWidth/2) - (16/2) + 'px'; | |
var rnd = Math.random()*4+2; | |
if(Math.random()*1 > 0.5){ | |
rnd *= -1; | |
} |
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
//gameLoop function.... | |
if(parseInt(ball.style.left) <= 0){ | |
scoreRight++; | |
document.getElementById('scoreRight').innerHTML = scoreRight; | |
gameChain(); | |
} | |
if(parseInt(ball.style.left) + 16 >= window.innerWidth){ | |
scoreLeft++; | |
document.getElementById('scoreLeft').innerHTML = scoreLeft; |
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
if(parseInt(ball.style.left) + 16 >= window.innerWidth){ | |
scoreLeft++; | |
document.getElementById('scoreLeft').innerHTML = scoreLeft; | |
} |
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
if(parseInt(ball.style.left) <= 0){ | |
scoreRight++; | |
document.getElementById('scoreRight').innerHTML = scoreRight; | |
} |
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
// stick değişkenleri | |
var stickLeft = document.getElementById('stickLeft'); | |
var stickRight = document.getElementById('stickRight'); | |
// ball değişkenleri | |
var ball = document.getElementById('ball'); | |
stickLeft.style.top = window.innerHeight/2 + 'px'; | |
stickRight.style.top = window.innerHeight/2 + 'px'; | |
ball.style.top = window.innerHeight/2 + 'px'; | |
ball.style.left = (window.innerWidth/2) - (16/2) + 'px'; |
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
// top sağ ve sol çubuklara çarparsa, Y ekseninde geri seksin | |
if(parseInt(ball.style.left) <= 0 + 16 && parseInt(ball.style.top) >= parseInt(stickLeft.style.top) && parseInt(ball.style.top) <= parseInt(stickLeft.style.top) + 85){ | |
ballLeft *= -1; | |
}else if(parseInt(ball.style.left) + 16 >= window.innerWidth - 12 && parseInt(ball.style.top) >= parseInt(stickRight.style.top) && parseInt(ball.style.top) <= parseInt(stickRight.style.top) + 85){ | |
ballLeft *= -1; | |
} |
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
// top üst ve alt bloklara çarparsa, X ekseninde geri seksin | |
if(parseInt(ball.style.top) <= 0 || parseInt(ball.style.top) + 16 >= window.height){ | |
ballTop *= -1; | |
} |
NewerOlder