Merge branch 'master' of github.com:glenux/wyrian

This commit is contained in:
Glenn Y. Rolland 2011-02-12 01:55:26 +01:00
commit 09d6f7c9a6
8 changed files with 8334 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,17 @@
<!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/DisplayController.js"></script>
<script type="text/javascript" src="js/InputController.js"></script>
<script type="text/javascript" src="js/GameController.js"></script>
<script type="text/javascript" src="js/Wyrian.js"></script>
</body>
</html>

7
js/DisplayController.js Normal file
View file

@ -0,0 +1,7 @@
var DisplayController = function() {
this.draw = function() {
};
};

26
js/GameController.js Normal file
View file

@ -0,0 +1,26 @@
var GameController = function(inputController, displayController) {
this._loopRunning = false;
this._loop = null;
this._inputController = inputController;
this._displayController = displayController;
this.start = function() {
this._loopRunning = true;
this._loop = setInterval(this.loop, 30);
};
this.stop = function() {
this._loopRunning = false;
};
this.loop = function() {
this._inputController.observe();
// add other stuff here
this._displayController.draw();
};
};

7
js/InputController.js Normal file
View file

@ -0,0 +1,7 @@
var InputController = function() {
this.observe = function() {
};
};

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

9
js/wyrian.js Normal file
View file

@ -0,0 +1,9 @@
var Wyrian = function() {
// do basic initializations
var inputController = new InputController(),
displayController = new DisplayController(),
gameController = new GameController(inputController, displayController);
gameController.start();
}();