Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener('keydown',function Down(e) {
- e.preventDefault();
- if(e.keyCode == 37){
- //left
- e.preventDefault();
- goLeftVar = setInterval(function GoLeft(){if(-3<drawX){ClearAndDraw();
- drawX = drawX - VelocityOfJetVarTWO;}/*left*/},VelocityOfJet);
- }
- if(e.keyCode == 38){
- //up
- e.preventDefault();
- goUpVar = setInterval(function GoUp(){if(drawY>-1){ClearAndDraw();
- drawY = drawY - VelocityOfJetVarTWO;}/*Up*/},VelocityOfJet);
- }
- if(e.keyCode == 39){
- //right
- e.preventDefault();
- goRightVar = setInterval(function GoRight(){if(701 > drawX){ClearAndDraw();
- drawX = drawX + VelocityOfJetVarTWO;}/*right*/},VelocityOfJet);
- }
- if(e.keyCode == 40){
- //down
- e.preventDefault();
- goDownVar = setInterval(function GoDown() {if(drawY < 461){ClearAndDraw();
- drawY = drawY + VelocityOfJetVarTWO;}/*down*/},VelocityOfJet);
- }
- },false);
- document.addEventListener('keyup',function Up(e) {
- e.preventDefault();
- if(e.keyCode == 37)
- //left
- {clearInterval(goLeftVar);}//left
- if(e.keyCode == 38)
- //up
- {clearInterval(goUpVar);}//up
- if(e.keyCode == 39)
- //right
- {clearInterval(goRightVar);}//right
- if(e.keyCode == 40)
- //down
- {clearInterval(goDownVar);}//down
- } ,false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement