This commit is contained in:
Arian Glander 2011-02-12 00:27:34 +01:00
parent b61241829a
commit 492a4561f2
4 changed files with 8282 additions and 0 deletions

45
css/style.css Normal file
View file

@ -0,0 +1,45 @@
#background {
width: 100%;
height: 100%;
background: black;
position: absolute;
top: 0;
right: 0;
z-index: 0;
}
#ground {
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
z-index: 30;
}
#game {
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
z-index: 60;
}
#hud {
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
z-index: 90;
}
#ship {
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
background: white;
}

View file

@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" media="all" href="css/style.css" />
</head>
<body>
<div id="background"></div>
<div id="ground"></div>
<div id="game"><div id="ship"></div></div>
<div id="hud"></div>
<script type="text/javascript" src="js/jquery-1.5.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>

8176
js/jquery-1.5.js vendored Normal file

File diff suppressed because it is too large Load diff

47
js/main.js Normal file
View file

@ -0,0 +1,47 @@
var keys = {};
function controlship() {
for (var i in keys) {
//a pressed
if (i == 65) {
$('#ship').css('left', (parseInt($('#ship').css('left'),10) - 10) + 'px');
}
// s pressed
if (i == 83) {
$('#ship').css('top', (parseInt($('#ship').css('top'),10) + 10) + 'px');
}
// d pressed
if (i == 68) {
$('#ship').css('left', (parseInt($('#ship').css('left'),10) + 10) + 'px');
}
// w pressed
if (i == 87) {
$('#ship').css('top', (parseInt($('#ship').css('top'),10) - 10) + 'px');
}
}
}
$(document).keydown(function (evt) {
var code = evt.keyCode || evt.which;
keys[code] = true;
});
$(document).keyup(function (evt) {
var code = evt.keyCode || evt.which;
delete keys[code];
});
function onTimerTick() {
controlship();
}
setInterval(onTimerTick, 33); // 33 milliseconds = ~ 30 frames per sec