diff --git a/herzle.html b/herzle.html index 5e8adfc..243c07e 100644 --- a/herzle.html +++ b/herzle.html @@ -20,14 +20,56 @@ t = -Math.PI/2; } - setTimeout("timed()", 100); + // setTimeout("timed()", 100); + } + + player_pos = 0; + + document.onkeydown = onKeyDown; + + function onKeyDown(e) { + e = e || window.event; + + var player = document.getElementById("player"); + + if (e.keyCode == '37') { // left + player_pos -= 10; + player.style.left = player_pos; + } + if (e.keyCode == '39') { // right + player_pos += 10; + player.style.left = player_pos; + } + if (e.keyCode == '32') { // space = fire + var pewpew = document.getElementById("pewpew"); + pewpew.innerHTML = "pew! pew!"; + } } + + -
- <3 + + <3 + < +