Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iLikeGrape committed Nov 18, 2024
1 parent 0b244b5 commit c2db9db
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spaceinvaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ window.onload = function() { //when game starts
}

requestAnimationFrame(update);
document.addEventListener("Keydown", moveShip())
}
function update(){
//preping for next frame
Expand All @@ -47,6 +48,10 @@ function update(){
}
context.clearRect(0, 0, board.width, board.height);


}

function moveShip() {
if (e.code == "ArrowLeft") { // checks to see if it should move left
if (e.code == "ArrowRight"){

Expand All @@ -63,7 +68,5 @@ function update(){
ship.y = Math.max(ship.y + 0.5, 436)
}
}
context.drawImage(shipImg, ship.x, ship.y, ship.width, ship.height);
context.drawImage(shipImg, ship.x, ship.y, ship.width, ship.height);
}


0 comments on commit c2db9db

Please sign in to comment.