forked from dwmkerr/spaceinvaders
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core game mechanics working, getting ready for a refactor of state/co…
…nfig
- Loading branch information
Dave Kerr
committed
Aug 20, 2013
1 parent
5b3cb08
commit 182890c
Showing
4 changed files
with
501 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
spaceinvaders.sublime-project | ||
spaceinvaders.sublime-workspace |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Space Invaders</title> | ||
<style> | ||
body { | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<canvas id="mainCanvas"></canvas> | ||
<p id="gameOver"></p> | ||
<p>Move Ship: Arrow Keys<br /> | ||
Fire: Space</p> | ||
<script src="spaceinvaders.js"></script> | ||
<script> | ||
window.addEventListener("keydown", function keydown(e) { | ||
var keycode; | ||
if (window.event) { | ||
keycode = window.event.keyCode; | ||
} | ||
else if (e) { | ||
keycode = e.which; | ||
} | ||
switch(keycode){ | ||
case 37: //left | ||
game.moveShip(-5); | ||
break; | ||
case 38: //down | ||
break; | ||
case 39: //right | ||
game.moveShip(5); | ||
break; | ||
case 40: //up | ||
break; | ||
case 32: //space | ||
game.shipFire(); | ||
break; | ||
}}); | ||
|
||
game.onGameLost = function onGameLost(game) { | ||
document.getElementById("gameOver").innerText = "You Lost!"; | ||
}; | ||
|
||
game.onGameWon = function onGameWon(game) { | ||
document.getElementById("gameOver").innerText = "You Won!"; | ||
}; | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.