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
function gameLoop(){ | |
//topun alacağı değerler | |
ball.style.top = pxAdd(parseInt(ball.style.top) + ballTop); | |
ball.style.left = pxAdd(parseInt(ball.style.left) + ballLeft); | |
} | |
setInterval(gameLoop, gameSpeed); |
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
// oyunun sürekli devam etmesi için gerekli yapı | |
function gameLoop(){ | |
// topun alacağı değerler | |
ball.style.top = pxAdd(parseInt(ball.style.top) + 2); | |
ball.style.left = pxAdd(parseInt(ball.style.left) + 2); | |
} | |
setInterval(gameLoop, 20); |
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
// #ball alacağı değerler | |
ball.style.top = pxAdd(parseInt(ball.style.top) + 2); | |
ball.style.left = pxAdd(parseInt(ball.style.left) + 2); |
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
// ball elementi üzerinde işlemler | |
var ball = document.getElementById('ball'); | |
ball.style.top = window.innerHeight/2 + 'px'; | |
ball.style.left = (window.innerWidth/2) + (16/2) + 'px'; |
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
// stick değişkenleri | |
var stickLeft = document.getElementById('stickLeft'); | |
var stickRight = document.getElementById('stickRight'); | |
stickLeft.style.top = window.innerHeight/2 + 'px'; | |
stickRight.style.top = window.innerHeight/2 + 'px'; | |
function pxAdd(numb){ | |
return numb + 'px'; | |
} |
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
switch(e.keyCode){ | |
// sol çubuk | |
case 87: | |
if(parseInt(stickLeft.style.top) <= 0){ | |
stickLeft.style.top = stickLeft.style.top; | |
}else{ | |
stickLeft.style.top = pxAdd(parseInt(stickLeft.style.top) - 30); | |
} | |
break; | |
case 83: |
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
document.onkeydown = function(e){ | |
switch(e.keyCode){ | |
// sol çubuk | |
case 87: | |
stickLeft.style.top = pxAdd(parseInt(stickLeft.style.top) - 30); | |
break; | |
case 83: | |
stickLeft.style.top = pxAdd(parseInt(stickLeft.style.top) + 30); | |
// sağ çubuk | |
case 38: |
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
function pxAdd(numb){ | |
return numb + 'px'; | |
} |
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
document.onkeydown = function(e){ | |
switch(e.keyCode){ | |
// sol çubuk | |
case 87: | |
console.log('w tusuna basildi'); | |
break; | |
case 83: | |
console.log('s tusuna basildi'); | |
// sağ çubuk | |
case 38: |
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
document.onkeydown = function(e){ | |
console.log(e); | |
} |