Skip to content

Instantly share code, notes, and snippets.

@kahilkubilay
Created December 26, 2019 22:54
Show Gist options
  • Save kahilkubilay/863916040260883460705dc2961245b1 to your computer and use it in GitHub Desktop.
Save kahilkubilay/863916040260883460705dc2961245b1 to your computer and use it in GitHub Desktop.
Javascript İle Oyun Yapımı: Nesnelerin Kontrolü - Çubuk
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:
stickRight.style.top = pxAdd(parseInt(stickRight.style.top) - 30)
break;
case 40:
stickRight.style.top = pxAdd(parseInt(stickRight.style.top) + 30);
break;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment