Commit guiltouf version

This commit is contained in:
Guillaume DE LA RUE 2011-02-12 15:55:38 +01:00
parent 218fd1753a
commit c3e9a3985f
70 changed files with 9100 additions and 0 deletions

74
conf/local.conf Normal file
View file

@ -0,0 +1,74 @@
# Listen for www
server {
# Config APP paths
set $root_path /Users/delarueguillaume/Sites/wyrian/wyrian/guiltouf;
# Server Config
listen 80;
server_name wyrian.socialmixmedia.fr;
access_log /var/log/nginx/wyrian.access.log;
# Set the max size for file uploads to 50Mb
client_max_body_size 50M;
location / {
root $root_path;
index index.php index.html index.htm;
# needed to forward user's IP address to rails
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_max_temp_file_size 0;
# sitemap generator
if ( $request_uri ~* ^/sitemap.xml ) {
rewrite ^(.*)$ /sitemap.php;
}
# Rewrite non static files request to /index.php
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1;
}
}
# Send php scripts to fastcgi
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $root_path/$fastcgi_script_name;
include fastcgi_params;
}
# Set long expireation date and no log access
location ~* ^.+\.(jpg|jpeg|gif|png|css|js)$ {
root $root_path;
access_log off;
expires 30d;
}
# Link common to core statics directly
location ^~ /common/ {
alias /Users/delarueguillaume/Sites/Framework-Web2ajaX/core/statics/;
access_log off;
expires 30d;
}
# Link to minify
location ^~ /min/ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /Users/delarueguillaume/Sites/Framework-Web2ajaX$fastcgi_script_name;
fastcgi_param WWW_PATH /Users/delarueguillaume/Sites/wyrian/wyrian;
include fastcgi_params;
}
# Deny access to protected dirs
location ~ ^/nginx-conf/(.*)$ { deny all; }
location ~ /\.ht { deny all; }
}

0
guiltouf/css/.empty Normal file
View file

48
guiltouf/css/style.css Normal file
View file

@ -0,0 +1,48 @@
.container {
}
.container .layout {
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
overflow: hidden;
}
#background {
background: transparent url(/images/debug-bg.jpg) repeat 0 0;
z-index: 0;
}
#ground {
z-index: 30;
}
#game {
z-index: 60;
}
#game .ship { border: 1px solid red; }
#game .ennemy { border: 1px solid blue; }
#hud {
z-index: 90;
}
#ship {
top: 50%;
left: 50%;
background: white;
}
/* Debug Panel */
#debug {
position: absolute;
display: block;
right: 10px;
top: 10px;
color:#fff;
z-index: 1000;
}

0
guiltouf/images/.empty Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
guiltouf/images/bullets/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
guiltouf/images/bullets/seed1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

BIN
guiltouf/images/bullets/shot1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

23
guiltouf/index.html Normal file
View file

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" media="all" href="css/style.css" />
</head>
<body>
<div id="debug">
yep
</div>
<div class="container">
<div id="background" class="layout"></div>
<div id="ground" class="layout"></div>
<div id="game" class="layout"><div id="ship"></div></div>
<div id="hud" class="layout"></div>
</div>
<script type="text/javascript" src="js/jquery-1.5.js"></script>
<script type="text/javascript" src="js/require.js"></script>
<script type="text/javascript" src="js/GameClass.js"></script>
<script type="text/javascript" src="js/Wyrian.js"></script>
</body>
</html>

0
guiltouf/js/.empty Normal file
View file

View file

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

171
guiltouf/js/GameClass.js Normal file
View file

@ -0,0 +1,171 @@
// Init Global vars
var FPS = 30;
var Stages = {} ;
var Level = 1 ;
var Layouts = {} ;
var timers = {} ;
var Game = null ;
var cos = Math.cos, sin = Math.sin, tan = Math.tan, exp = Math.exp, log = Math.log, pow = Math.pow ;
// -- Init scene prototype
var app = function(opts) {
this.version = 0.1 ;
// Init uniqId
this.uniqId = 0 ;
// Default settings
var settings = {
libs: {}
} ;
$.extend(true, settings, opts);
this.settings = settings ;
// If canvas supported in native or use extended support for croos browsing like excnvas for ie
this.support = this.support || {} ;
if ( typeof G_vmlCanvasManager != 'undefined' ) {
this.support.canvas = {extended: true} ;
} else {
this.support.canvas = {isNative: true} ;
}
// Listen for inputs
this.input = new this.Input() ;
// Return object
return this;
} ;
// -- Bind init call
app.prototype.init = function() {
var self = this ;
require({
baseUrl: "/js/",
urlArgs: "bust=" + self.version
},
// -- Layout to load
self.settings.layers,
// -- All objects are loaded => can run
function() {
$(document).trigger('gameLoaded') ;
}
);
if ( typeof this.settings.init == 'function') {
this.settings.init() ;
}
} ;
// -- A log function
app.prototype.log = function(txt) {
try {
console.log(txt);
} catch(e) {} ;
}
// -- Call all canvas updates if declared as 'running'
app.prototype.loopAnimation = function() {
// -- Build an active elements list
this.activeEls = [] ;
// -- Search for elements that have to be updated
for ( var i in Layouts ) {
var _layout = Layouts[i] ;
if ( _layout && _layout.running ) {
_layout.update() ;
}
}
// -- Create ennemies
var numEnnemies = 0 ;
for ( var i in Layouts.Ennemies.els ) {
var _el = Layouts.Ennemies.els[i] ;
if ( ! _el.deleteAfter ) numEnnemies++ ;
}
$('#debug').html(numEnnemies) ;
for ( var i = numEnnemies-1 ; i < Level + 2 ; i++ ) {
Layouts.Ennemies.createRandom() ;
}
}
// -- Bind Inputs
app.prototype.Input = function() {
this.keyboard = {};
var that = this;
this.mousedown = false;
this.keydown = true;
// this is handling WASD, and arrows keys
function update_keyboard(e, val) {
if(e.keyCode==40 || e.keyCode==83)
that.keyboard['down'] = val;
if(e.keyCode==38 || e.keyCode==87)
that.keyboard['up'] = val;
if(e.keyCode==39 || e.keyCode==68)
that.keyboard['right'] = val;
if(e.keyCode==37 || e.keyCode==65)
that.keyboard['left'] = val;
if(e.keyCode==32) {
that.keyboard['space'] = val;
e.preventDefault() ;
e.stopPropagation() ;
}
if(e.keyCode==17)
that.keyboard['ctrl'] = val;
if(e.keyCode==13)
that.keyboard['enter'] = val;
};
document.ontouchstart = function(event) {
that.mousedown = true;
}
document.ontouchend = function(event) {
that.mousedown = false;
}
document.ontouchmove = function(event) {}
document.onmousedown = function(event) {
that.mousedown = true;
}
document.onmouseup = function(event) {
that.mousedown = false;
}
document.onclick = function(event) {
//that.click(event);
}
/*
document.onmousemove = function(event) {
that.xmouse = event.clientX;
that.ymouse = event.clientY;
}
*/
document.onkeydown = function(e) {
that.keydown = true;
update_keyboard(e, true);
};
document.onkeyup = function(e) {
that.keydown = false;
update_keyboard(e, false);
};
// can be used to avoid key jamming
document.onkeypress = function(e) {
if ( that.keyboard.space ) {
e.preventDefault() ;
e.stopPropagation() ;
}
};
// make sure that the keyboard is rested when
// the user leave the page
window.onblur = function (e) {
that.keyboard = {}
that.keydown = false;
that.mousedown = false;
}
}

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();
};
};

View file

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

182
guiltouf/js/LayoutClass.js Normal file
View file

@ -0,0 +1,182 @@
// -- Build Background Scene
var Layout = function(opts) {
// -- Default settings
var settings = {
el: [],
dom: null
} ;
$.extend(settings, opts) ;
// -- Set running or not
this.running = true ;
// -- Store settings
this.settings = settings ;
// -- Declare Scene here
this.dom = this.settings.dom.get(0) ;
// -- Set width and height shortcuts
this.width = this.settings.dom.width() ;
this.height = this.settings.dom.height() ;
// -- Create objects in scene
this.els = [] ;
if ( typeof settings.el == 'object' ) {
for ( var i in settings.el ) {
this.els.push(this.createObj(settings.el[i])) ;
}
}
return this;
};
// -- Return or set settings
Layout.prototype.option = function(optName, optValue) {
// No params => return all settings
if ( typeof optName == 'undefined' ) return this.settings;
// If optName and optValue set => modify it
else if ( typeof optValue != 'undefined' ) this.settings[optName] = this.settings ;
// In other cases, simply return the setting value
else return this.settings[optName] ;
};
// -- Return an object by name
Layout.prototype.getObj = function(name) {
this.cache = this.cache || {} ;
if ( this.cache[name] ) return this.cache[name] ;
for ( var i in this.els ) {
if ( this.els[i].settings.name == name ) {
this.cache[name] = this.els[i] ;
return this.cache[name] ;
}
}
}
// -- Update elements into layout
Layout.prototype.update = function() {
for ( var j in this.els ) {
var _el = this.els[j] ;
if ( _el ) {
if( ! _el.deleteAfter ) {
_el.animate() ;
}
else {
_el.box.addClass('removed').remove() ;
}
}
}
}
// -- Create an object
Layout.prototype.createObj = function(opts) {
var self = this ;
// -- Init and build Framebuffer object
var Obj = function (optsObj) {
// -- Parse options
var settingsObj = {
origin: { x: 0, y: 0},
imageSrc: false,
backgroundColor: 'transparent',
backgroundRepeat: 'no-repeat',
backgroundPosition: '0 0',
imageOrigin: { x:0, y:0 }
} ;
$.extend(true, settingsObj, optsObj) ;
// -- Store options
this.name = settingsObj.name || 'default' ;
this.id = settingsObj.id || Wyrian.uniqId++ ;
this.width = settingsObj.width ? settingsObj.width : self.width ;
this.height = settingsObj.height ? settingsObj.height : self.height ;
this.settings = settingsObj ;
// -- Find backgroundImage in CSS if specified
if ( ! settingsObj.imageSrc ) {
var bgImg = self.settings.dom.css('backgroundImage') ;
if ( bgImg != 'none' ) {
settingsObj.imageSrc = bgImg ;
}
}
// -- Init position
this.init() ;
// -- Create a DOM object
this.box = $('<div>', {
class:'sprite '+this.name,
id: 'element_'+this.id,
css: {
position: 'absolute',
display: 'block',
top: 0,
left: 0,
width: this.width,
height: this.height,
backgroundColor: settingsObj.backgroundColor,
backgroundRepeat: settingsObj.backgroundRepeat,
backgroundPosition: settingsObj.backgroundPosition,
backgroundImage: settingsObj.imageSrc ? 'url('+settingsObj.imageSrc+')' : ''
}
}).transform({'translate': this.x+'px, '+this.y+'px'}) ;
// -- Append to scene
this.box.appendTo(self.dom) ;
} ;
// -- Init
Obj.prototype.init = function() {
this.x = this.settings.origin.x ;
this.y = this.settings.origin.y ;
} ;
// -- Draw object into scene
Obj.prototype.draw = function() {
if ( (this.y >= -this.height) && (this.y <= (self.height+this.height)) && this.x >= -this.width && this.x <= (self.width+this.width) ) {
// -- Set sprite to display
if ( this.settings.sprites ) {
this.lastSprite = this.lastSprite || 0 ;
this.lastSprite++ ;
if ( this.lastSprite >= this.settings.sprites.length )
this.lastSprite = 0 ;
this.box.css({'backgroundPosition': -1*this.lastSprite*this.settings.width+'px 0'}) ;
}
// -- Move div
this.box.transform({'translate': this.x+'px, '+this.y+'px'}) ;
}
} ;
// -- Animate the Framebuffer into the scene
Obj.prototype.animate = function() {
if ( $.isFunction(this.settings.animate) ) {
this.parent = self ;
this.settings.animate(this) ;
this.draw(this) ;
} else {
this.draw() ;
}
}
// -- Remove object
Obj.prototype.deleteObj = function() {
this.deleteAfter = true ;
}
return new Obj(opts) ;
};

78
guiltouf/js/Wyrian.js Normal file
View file

@ -0,0 +1,78 @@
/**************************************************************************
* Init Game Bootstrap
***************************************************************************/
Wyrian = new app({
'libs': [
'order!jquery.transform-0.9.3.min',
'order!DisplayController',
'order!InputController',
'order!GameController'
],
'layers': [
'order!LayoutClass',
'order!layouts/BgLayer',
'order!layouts/PlayerLayer',
'order!layouts/Ennemies'
]
}) ;
// Init Application and bind all games events
jQuery(document).ready(function() {
/**************************************************************************
* Load Dependencies & Create Application
***************************************************************************/
require({
baseUrl: "/js/",
urlArgs: "bust=" + Wyrian.version
}, Wyrian.settings.libs,
// -- All objects are loaded => can run
function() {
// -- Init Stage or show IE popup
if ( ! $.browser.msie ) {
Wyrian.init() ;
} else {
$.facebox.settings.opacity = 0.8 ;
$.facebox.settings.closeImage = '/common/img/facebox/apple-close.png' ;
$(document).unbind('close.facebox') ;
$.facebox({ajax: '/popup-ie/'}, 'popup-ie' ) ;
}
}
);
/**************************************************************************
* Game Controls Events
***************************************************************************/
// -- Game is loaded
$(document).bind('gameLoaded', function(e, res) {
if ( timers.loopGame ) clearInterval(timers.loopGame) ;
timers.loopGame = setInterval(Wyrian.loopAnimation, 1000/FPS) ;
});
// -- Init Game
$(document).bind('gameInit', function(e, res) {
$(document).trigger('gameReset') ;
}) ;
// -- Game Reset
$(document).bind('gameReset', function(e, res) {
}) ;
// -- Start Animation
$(document).bind('gameStart', function(e, res) {
}) ;
// -- On Complete Launch
$(document).bind('gameComplete', function(e, res) {
}) ;
}) ;

8176
guiltouf/js/jquery-1.5.js vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,22 @@
// -- Init the Background DIV
Layouts.Background = new Layout({
// -- Define elements to draw with options
el: [{
id: 'ground',
animate: function(obj) {
obj.y -= obj.parent.settings.speed*obj.parent.settings.direction;
obj.parent.settings.dom.css({backgroundPosition: '0 '+obj.y+'px'}) ;
}
}],
// -- Define current Speed
speed: 5,
direction: -1,
// -- Define canvas parent
dom: $('div#background')
}) ;

View file

@ -0,0 +1,39 @@
// -- Init the Background DIV
Layouts.Ennemies = new Layout({
// -- Define elements to draw with options
el: [],
// -- Define current Speed
speed: 7,
direction: 1,
// -- Define canvas parent
dom: $('div#game')
}) ;
// -- Create a random ennemy
Layouts.Ennemies.createRandom = function(opts) {
var bulletConf = {
name: 'ennemy',
width: 60,
height: 60,
power: 40,
imageSrc: '/images/bullet-electric-sprite.png',
sprites: [0,1,2],
speed: Math.round(Math.max(10, Math.random()*30)),
direction: 1,
origin: {x:Math.round(Math.random()*this.width), y:0},
animate: function (obj) {
if ( obj.deleteAfter ) return false;
obj.y += obj.settings.speed*obj.settings.direction ;
if ( obj.y > obj.parent.height ) {
obj.deleteAfter = true ;
}
}
} ;
this.els.push(this.createObj(bulletConf)) ;
} ;

View file

@ -0,0 +1,142 @@
// -- Init the Background DIV
Layouts.Player = new Layout({
// -- Define elements to draw with options
el: [{
name: 'ship',
width: 200,
height: 80,
fireInterval: 300,
animate: function(obj) {
// -- KEY up /down
if ( Wyrian.input.keyboard.up && obj.y > 0 ) {
obj.y -= obj.parent.settings.speed ;
}
if ( Wyrian.input.keyboard.down && (obj.y < (obj.parent.height-obj.height) ) ) {
obj.y += obj.parent.settings.speed;
}
// -- Left/Right move : choose sprite sequence to display
if ( Wyrian.input.keyboard.left && (obj.x > 0)) {
obj.spriteIndex = 0 ;
obj.x -= obj.parent.settings.speed;
}
else if ( Wyrian.input.keyboard.right && (obj.x < obj.parent.width-obj.width) ) {
obj.spriteIndex = 2 ;
obj.x += obj.parent.settings.speed;
}
else {
obj.spriteIndex = 1 ;
}
// -- Press Space : fire
if ( Wyrian.input.keyboard.space ) {
obj.parent.fire(obj) ;
}
}
}],
// -- Define current Speed
speed: 20,
direction: 1,
// -- Define canvas parent
dom: $('div#game')
}) ;
// -- Bullets types
Layouts.Player.bulletLib = function(obj, bulletType) {
var bulletConf = {
power: 40,
imageSrc: '/images/bullet-electric-sprite.png',
sprites: [0,1,2],
speed: 40,
direction: -1,
origin: {x:0, y:0}
} ;
// -- Default Left
if ( bulletType == 'default_left' ) {
bulletConf.width = 16 ;
bulletConf.height = 64 ;
bulletConf.sprites = false ;
bulletConf.imageSrc = '/images/12px-long-blue.png' ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x+8+obj.width/2 ;
bulletConf.origin.y = obj.y - bulletConf.height ;
}
// -- Default Right
if ( bulletType == 'default_right' ) {
bulletConf.width = 16 ;
bulletConf.height = 64 ;
bulletConf.sprites = false ;
bulletConf.imageSrc = '/images/12px-long-blue.png' ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x-8+obj.width/2 ;
bulletConf.origin.y = obj.y - bulletConf.height ;
}
// -- Big Left
if ( bulletType == 'big_left' ) {
bulletConf.width = 60 ;
bulletConf.height = 60 ;
bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x+30+obj.width/2 ;
bulletConf.origin.y = obj.y + 30 - bulletConf.height ;
}
// -- Big Left
if ( bulletType == 'big_right' ) {
bulletConf.width = 60 ;
bulletConf.height = 60 ;
bulletConf.speed = 20 ;
bulletConf.name = 'bullet' ;
bulletConf.origin.x = obj.x-60+obj.width/2 ;
bulletConf.origin.y = obj.y + 30 - bulletConf.height ;
}
// -- The animate function
bulletConf.animate = function(obj) {
if ( obj.deleteAfter ) return false;
obj.y += obj.settings.speed*obj.settings.direction ;
if ( obj.y < -obj.height ) {
obj.deleteObj() ;
}
} ;
// Add the bullet to display
return this.createObj(bulletConf) ;
} ;
// -- Fire bullets on space bar
Layouts.Player.fire = function(obj) {
// Get now time and lastfired
this.now = (new Date().getTime()) ;
this.lastFired = this.lastFired || this.now ;
// If firing, wait for next interval
if ( (this.now-this.lastFired) < (obj.settings.fireInterval) ) return false;
// Store now for last fired event
this.lastFired = this.now ;
// Create new bullets
var bullets = [] ;
bullets.push(this.bulletLib(obj, 'default_left')) ;
bullets.push(this.bulletLib(obj, 'default_right')) ;
bullets.push(this.bulletLib(obj, 'big_left')) ;
bullets.push(this.bulletLib(obj, 'big_right')) ;
for ( var i in bullets ) {
this.els.push(bullets[i]) ;
}
}

View file

47
guiltouf/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

47
guiltouf/js/require.js Normal file
View file

@ -0,0 +1,47 @@
/*
RequireJS 0.22.0 Copyright (c) 2010, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
RequireJS i18n Copyright (c) 2010, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
RequireJS text Copyright (c) 2010, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
RequireJS order Copyright (c) 2010, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var require,define;
(function(){function E(e){return A.call(e)==="[object Function]"}function K(e){return A.call(e)==="[object Array]"}function M(e,f,m){for(var l in f)if(!(l in L)&&(!(l in e)||m))e[l]=f[l];return h}function v(e,f,m){var l,y,o;for(l=0;o=f[l];l++){o=typeof o==="string"?{name:o}:o;y=o.location;if(m&&(!y||y.indexOf("/")!==0&&y.indexOf(":")===-1))o.location=m+"/"+(o.location||o.name);o.location=o.location||o.name;o.lib=o.lib||"lib";o.main=(o.main||"lib/main").replace(r,"");e[o.name]=o}}function j(e){function f(a){var b,
c;for(b=0;c=a[b];b++)if(c==="."){a.splice(b,1);b-=1}else if(c==="..")if(b===1&&(a[2]===".."||a[0]===".."))break;else if(b>0){a.splice(b-1,2);b-=2}}function m(a,b){var c;if(a.charAt(0)===".")if(b){if(C.packages[b])b=[b];else{b=b.split("/");b=b.slice(0,b.length-1)}a=b.concat(a.split("/"));f(a);c=C.packages[b=a[0]];a=a.join("/");if(c&&a===b+"/"+c.main)a=b}return a}function l(a,b){var c=a?a.indexOf("!"):-1,d=null,g=b?b.name:null,p=a,n,u;if(c!==-1){d=a.substring(0,c);a=a.substring(c+1,a.length)}if(d){d=
m(d,g);d=ya[d]||d}if(a){if(d)n=(c=x[d])?c.normalize?c.normalize(a,function(z){return m(z,g)}):m(a,g):"__$p"+g+"@"+a;else n=m(a,g);u=ga[n];if(!u){u=h.toModuleUrl?h.toModuleUrl(i,a,b):i.nameToUrl(a,null,b);ga[n]=u}}return{prefix:d,name:n,parentMap:b,url:u,originalName:p,fullName:d?d+"!"+n:n}}function y(){var a=true,b=C.priorityWait,c,d;if(b){for(d=0;c=b[d];d++)if(!G[c]){a=false;break}a&&delete C.priorityWait}return a}function o(a){return function(b){a.exports=b}}function ca(a,b,c){return function(){var d=
[].concat(B.call(arguments,0)),g;if(c&&E(g=d[d.length-1]))g.__requireJsBuild=true;d.push(b);return a.apply(null,d)}}function na(a,b){b=ca(i.require,a,b);M(b,{nameToUrl:ca(i.nameToUrl,a),toUrl:ca(i.toUrl,a),isDefined:ca(i.isDefined,a),ready:h.ready,isBrowser:h.isBrowser});if(h.paths)b.paths=h.paths;return b}function za(a){var b,c,d,g,p,n,u,z=da[a];if(z)for(g=0;c=z[g];g++){b=c.fullName;c=l(c.originalName,c.parentMap);c=c.fullName;d=F[b];if(c!==b){F[c]=d;delete F[b];for(p=0;p<d.length;p++){u=d[p].depArray;
for(n=0;n<u.length;n++)if(u[n]===b)u[n]=c}}}delete da[a]}function oa(a){var b=a.prefix,c=a.fullName;if(!(X[c]||c in x)){if(b&&!W[b]){W[b]=undefined;(da[b]||(da[b]=[])).push(a);(F[b]||(F[b]=[])).push({onDep:function(d){d===b&&za(b)}});oa(l(b))}i.paused.push(a)}}function ha(a){var b,c,d;b=a.callback;var g=a.fullName;d=[];var p=a.depArray;if(b&&E(b)){if(p)for(b=0;b<p.length;b++)d.push(a.deps[p[b]]);c=h.execCb(g,a.callback,d);if(g)if(a.usingExports&&c===undefined&&(!a.cjsModule||!("exports"in a.cjsModule)))c=
x[g];else if(a.cjsModule&&"exports"in a.cjsModule)c=x[g]=a.cjsModule.exports;else{if(g in x&&!a.usingExports)return h.onError(new Error(g+" has already been defined"));x[g]=c}}else if(g)c=x[g]=b;if(g)if(d=F[g]){for(b=0;b<d.length;b++)d[b].onDep(g,c);delete F[g]}if(S[a.waitId]){delete S[a.waitId];a.isDone=true;i.waitCount-=1;if(i.waitCount===0)ia=[]}}function pa(a,b,c,d){a=l(a,d);var g=a.name,p=a.fullName,n={waitId:g||R+Aa++,depCount:0,depMax:0,prefix:a.prefix,name:g,fullName:p,deps:{},depArray:b,
callback:c,onDep:function(qa,Ba){if(!(qa in n.deps)){n.deps[qa]=Ba;n.depCount+=1;n.depCount===n.depMax&&ha(n)}}},u,z;if(p){if(p in x||G[p]===true)return;X[p]=true;G[p]=true;i.jQueryDef=p==="jquery"}for(c=0;c<b.length;c++)if(u=b[c]){u=l(u,g?a:d);z=u.fullName;b[c]=z;if(z==="require")n.deps[z]=na(a);else if(z==="exports"){n.deps[z]=x[p]={};n.usingExports=true}else if(z==="module"){n.cjsModule=u=n.deps[z]={id:g,uri:g?i.nameToUrl(g,null,d):undefined};u.setExports=o(u)}else if(z in x&&!(z in S))n.deps[z]=
x[z];else{n.depMax+=1;oa(u);(F[z]||(F[z]=[])).push(n)}}if(n.depCount===n.depMax)ha(n);else{S[n.waitId]=n;ia.push(n);i.waitCount+=1}}function Y(a){pa.apply(null,a);G[a[0]]=true}function ra(a){if(!i.jQuery)if((a=a||(typeof jQuery!=="undefined"?jQuery:null))&&"readyWait"in a){i.jQuery=a;Y(["jquery",[],function(){return jQuery}]);if(i.scriptCount){a.readyWait+=1;i.jQueryIncremented=true}}}function sa(a,b){if(!a.isDone){var c=a.fullName,d=a.depArray,g,p;if(c){if(b[c])return x[c];b[c]=true}for(p=0;p<d.length;p++)(g=
d[p])&&!a.deps[g]&&S[g]&&a.onDep(g,sa(S[g],b));return c?x[c]:undefined}}function ja(){var a=C.waitSeconds*1E3,b=a&&i.startTime+a<(new Date).getTime();a="";var c=false,d=false,g;if(C.priorityWait)if(y())Z();else return;for(g in G)if(!(g in L)){c=true;if(!G[g])if(b)a+=g+" ";else{d=true;break}}if(c||i.waitCount){if(b&&a){g=new Error("require.js load timeout for modules: "+a);g.requireType="timeout";g.requireModules=a;return h.onError(g)}if(d||i.scriptCount){if(H||N)setTimeout(ja,50)}else if(i.waitCount){for(T=
0;a=ia[T];T++)sa(a,{});ja()}else h.checkReadyState()}}function ta(a,b){var c=b.name,d=b.fullName;if(!(d in x)){W[a]||(W[a]=x[a]);G[d]||(G[d]=false);W[a].load(c,na(b.parentMap,true),function(g){require.onPluginLoad&&require.onPluginLoad(i,a,c,g);ha({prefix:b.prefix,name:b.name,fullName:b.fullName,callback:g});G[d]=true},C)}}function Ca(a){if(a.prefix&&a.name.indexOf("__$p")===0&&x[a.prefix])a=l(a.originalName,a.parentMap);var b=a.prefix,c=a.fullName;if(!(X[c]||c in x)){X[c]=true;if(b)if(x[b])ta(b,
a);else{if(!$[b]){$[b]=[];(F[b]||(F[b]=[])).push({onDep:function(d){if(d===b){var g,p=$[b];for(d=0;d<p.length;d++){g=p[d];ta(b,l(g.originalName,g.parentMap))}delete $[b]}}})}$[b].push(a)}else h.load(i,c,a.url)}}var i,Z,C={waitSeconds:7,baseUrl:w.baseUrl||"./",paths:{},packages:{}},aa=[],X={require:true,exports:true,module:true},ga={},x={},G={},S={},ia=[],Aa=0,F={},W={},$={},da={};Z=function(){var a,b,c;if(i.scriptCount<=0)i.scriptCount=0;for(;aa.length;){a=aa.shift();if(a[0]===null)return h.onError(new Error("Mismatched anonymous require.def modules"));
else Y(a)}if(!(C.priorityWait&&!y())){for(;i.paused.length;){c=i.paused;i.paused=[];for(b=0;a=c[b];b++)Ca(a);i.startTime=(new Date).getTime()}ja()}};i={contextName:e,config:C,defQueue:aa,waiting:S,waitCount:0,specified:X,loaded:G,urlMap:ga,scriptCount:0,urlFetched:{},defined:x,paused:[],plugins:W,managerCallbacks:F,makeModuleMap:l,normalize:m,configure:function(a){var b,c,d;if(a.baseUrl)if(a.baseUrl.charAt(a.baseUrl.length-1)!=="/")a.baseUrl+="/";b=C.paths;c=C.packages;M(C,a,true);if(a.paths){for(d in a.paths)d in
L||(b[d]=a.paths[d]);C.paths=b}if((b=a.packagePaths)||a.packages){if(b)for(d in b)d in L||v(c,b[d],d);a.packages&&v(c,a.packages);C.packages=c}if(a.priority){c=i.requireWait;i.requireWait=false;i.require(a.priority);i.requireWait=c;C.priorityWait=a.priority}if(a.deps||a.callback)i.require(a.deps||[],a.callback);a.ready&&h.ready(a.ready)},isDefined:function(a,b){return l(a,b).fullName in x},require:function(a,b,c){if(typeof a==="string"){if(h.get)return h.get(i,a,b);c=b;b=l(a,c);a=x[b.fullName];if(a===
undefined)return h.onError(new Error("require: module name '"+b.fullName+"' has not been loaded yet for context: "+e));return a}pa(null,a,b,c);if(!i.requireWait)for(;!i.scriptCount&&i.paused.length;)Z()},takeGlobalQueue:function(){if(O.length){D.apply(i.defQueue,[i.defQueue.length-1,0].concat(O));O=[]}},completeLoad:function(a){var b;for(i.takeGlobalQueue();aa.length;){b=aa.shift();if(b[0]===null){b[0]=a;break}else if(b[0]===a)break;else{Y(b);b=null}}b?Y(b):Y([a,[],a==="jquery"&&typeof jQuery!=="undefined"?
function(){return jQuery}:null]);G[a]=true;ra();if(h.isAsync)i.scriptCount-=1;Z();h.isAsync||(i.scriptCount-=1)},toUrl:function(a,b){var c=a.lastIndexOf("."),d=null;if(c!==-1){d=a.substring(c,a.length);a=a.substring(0,c)}return i.nameToUrl(a,d,b)},nameToUrl:function(a,b,c){var d,g,p,n,u=i.config;if(a.indexOf("./")===0||a.indexOf("../")===0){c=c&&c.url?c.url.split("/"):[];c.length&&c.pop();c=c.concat(a.split("/"));f(c);b=c.join("/")+(b?b:h.jsExtRegExp.test(a)?"":".js")}else{a=m(a,c);if(h.jsExtRegExp.test(a))b=
a+(b?b:"");else{d=u.paths;g=u.packages;c=a.split("/");for(n=c.length;n>0;n--){p=c.slice(0,n).join("/");if(d[p]){c.splice(0,n,d[p]);break}else if(p=g[p]){a=a===p.name?p.location+"/"+p.main:p.location+"/"+p.lib;c.splice(0,n,a);break}}b=c.join("/")+(b||".js");b=(b.charAt(0)==="/"||b.match(/^\w+:/)?"":u.baseUrl)+b}}return u.urlArgs?b+((b.indexOf("?")===-1?"?":"&")+u.urlArgs):b}};i.jQueryCheck=ra;i.resume=Z;return i}function s(){var e,f,m;if(I&&I.readyState==="interactive")return I;e=document.getElementsByTagName("script");
for(f=e.length-1;f>-1&&(m=e[f]);f--)if(m.readyState==="interactive")return I=m;return null}var k=/(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,q=/require\(["']([^'"\s]+)["']\)/g,r=/^\.\//,A=Object.prototype.toString,t=Array.prototype,B=t.slice,D=t.splice,H=!!(typeof window!=="undefined"&&navigator&&document),N=!H&&typeof importScripts!=="undefined",P=H&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,R="_r@@",L={},J={},O=[],I=null,Da=false,ua=false,ya={text:"require/text",i18n:"require/i18n",
order:"require/order"},h;t={};var ka,w,U,ea,la,ba,va,Q,wa,fa,T,ma,xa,V;if(typeof require!=="undefined")if(E(require))return;else t=require;h=require=function(e,f,m){var l="_",y;if(!K(e)&&typeof e!=="string"){y=e;if(K(f)){e=f;f=m}else e=[]}if(y&&y.context)l=y.context;m=J[l]||(J[l]=j(l));y&&m.configure(y);return m.require(e,f)};h.version="0.22.0";h.isArray=K;h.isFunction=E;h.mixin=M;h.jsExtRegExp=/^\/|:|\?|\.js$/;w=h.s={contexts:J,skipAsync:{},isPageLoaded:!H,readyCalls:[]};if(h.isAsync=h.isBrowser=
H){U=w.head=document.getElementsByTagName("head")[0];if(ea=document.getElementsByTagName("base")[0])U=w.head=ea.parentNode}h.onError=function(e){throw e;};h.load=function(e,f,m){var l=e.contextName,y=e.urlFetched,o=e.loaded;Da=false;o[f]||(o[f]=false);if(!y[m]){e.scriptCount+=1;h.attach(m,l,f);y[m]=true;if(e.jQuery&&!e.jQueryIncremented){e.jQuery.readyWait+=1;e.jQueryIncremented=true}}};define=h.def=function(e,f,m){var l;if(typeof e!=="string"){m=f;f=e;e=null}if(!h.isArray(f)){m=f;f=[]}if(!e&&!f.length&&
h.isFunction(m))if(m.length){m.toString().replace(k,"").replace(q,function(y,o){f.push(o)});f=["require","exports","module"].concat(f)}if(ua){l=ka||s();if(!l)return h.onError(new Error("ERROR: No matching script interactive for "+m));e||(e=l.getAttribute("data-requiremodule"));l=J[l.getAttribute("data-requirecontext")]}(l?l.defQueue:O).push([e,f,m])};h.execCb=function(e,f,m){return f.apply(null,m)};h.onScriptLoad=function(e){var f=e.currentTarget||e.srcElement,m;if(e.type==="load"||P.test(f.readyState)){I=
null;e=f.getAttribute("data-requirecontext");m=f.getAttribute("data-requiremodule");J[e].completeLoad(m);f.removeEventListener?f.removeEventListener("load",h.onScriptLoad,false):f.detachEvent("onreadystatechange",h.onScriptLoad)}};h.attach=function(e,f,m,l,y){var o;if(H){l=l||h.onScriptLoad;o=document.createElement("script");o.type=y||"text/javascript";o.charset="utf-8";o.async=!w.skipAsync[e];o.setAttribute("data-requirecontext",f);o.setAttribute("data-requiremodule",m);if(o.addEventListener)o.addEventListener("load",
l,false);else{ua=true;o.attachEvent("onreadystatechange",l)}o.src=e;ka=o;ea?U.insertBefore(o,ea):U.appendChild(o);ka=null;return o}else if(N){l=J[f];f=l.loaded;f[m]=false;importScripts(e);l.completeLoad(m)}return null};w.baseUrl=t.baseUrl;if(H&&(!w.baseUrl||!U)){la=document.getElementsByTagName("script");va=t.baseUrlMatch?t.baseUrlMatch:/(allplugins-)?require\.js(\W|$)/i;for(T=la.length-1;T>-1&&(ba=la[T]);T--){if(!U)U=ba.parentNode;if(!fa&&(fa=ba.getAttribute("data-main"))){t.deps=t.deps?t.deps.concat(fa):
[fa];if(!t.baseUrl&&(Q=ba.src)){Q=Q.split("/");Q.pop();w.baseUrl=t.baseUrl=Q.length?Q.join("/"):"./"}}if(!w.baseUrl&&(Q=ba.src))if(wa=Q.match(va)){w.baseUrl=Q.substring(0,wa.index);break}}}h.pageLoaded=function(){if(!w.isPageLoaded){w.isPageLoaded=true;ma&&clearInterval(ma);if(xa)document.readyState="complete";h.callReady()}};h.checkReadyState=function(){var e=w.contexts,f;for(f in e)if(!(f in L))if(e[f].waitCount)return;w.isDone=true;h.callReady()};h.callReady=function(){var e=w.readyCalls,f,m,l;
if(w.isPageLoaded&&w.isDone){if(e.length){w.readyCalls=[];for(f=0;m=e[f];f++)m()}e=w.contexts;for(l in e)if(!(l in L)){f=e[l];if(f.jQueryIncremented){f.jQuery.readyWait-=1;f.jQueryIncremented=false}}}};h.ready=function(e){w.isPageLoaded&&w.isDone?e():w.readyCalls.push(e);return h};if(H){if(document.addEventListener){document.addEventListener("DOMContentLoaded",h.pageLoaded,false);window.addEventListener("load",h.pageLoaded,false);if(!document.readyState){xa=true;document.readyState="loading"}}else if(window.attachEvent){window.attachEvent("onload",
h.pageLoaded);if(self===self.top)ma=setInterval(function(){try{if(document.body){document.documentElement.doScroll("left");h.pageLoaded()}}catch(e){}},30)}document.readyState==="complete"&&h.pageLoaded()}h(t);if(typeof setTimeout!=="undefined"){V=w.contexts[t.context||"_"];V.requireWait=true;setTimeout(function(){V.requireWait=false;V.takeGlobalQueue();V.jQueryCheck();V.scriptCount||V.resume();h.checkReadyState()},0)}})();
(function(){function E(v,j,s,k,q,r){if(j[v]){s.push(v);if(j[v]===true||j[v]===1)k.push(q+v+"/"+r)}}function K(v,j,s,k,q){j=k+j+"/"+q;require._fileExists(v.nameToUrl(j,null))&&s.push(j)}var M=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;define("require/i18n",{load:function(v,j,s,k){k=k||{};var q=M.exec(v),r=q[1],A=q[4],t=q[5],B=A.split("-"),D=[],H={},N,P,R="";if(q[5]){r=q[1];v=r+t}else{v=v;t=q[4];A=k.locale||(k.locale=typeof navigator==="undefined"?"root":(navigator.language||navigator.userLanguage||
"root").toLowerCase());B=A.split("-")}if(k.isBuild){D.push(v);K(j,"root",D,r,t);for(N=0;P=B[N];N++){R+=(R?"-":"")+P;K(j,R,D,r,t)}j(D);s()}else j([v],function(L){var J=[];E("root",L,J,D,r,t);for(N=0;P=B[N];N++){R+=(R?"-":"")+P;E(R,L,J,D,r,t)}j(D,function(){var O,I;for(O=J.length-1;O>-1&&(P=J[O]);O--){I=L[P];if(I===true||I===1)I=j(r+P+"/"+t);require.mixin(H,I)}s(H)})})}})})();
(function(){var E=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],K=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,M=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,v=[];if(!require.textStrip)require.textStrip=function(j){if(j){j=j.replace(K,"");var s=j.match(M);if(s)j=s[1]}else j="";return j};if(!require.jsEscape)require.jsEscape=function(j){return j.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,
"\\r")};if(!require.getXhr)require.getXhr=function(){var j,s,k;if(typeof XMLHttpRequest!=="undefined")return new XMLHttpRequest;else for(s=0;s<3;s++){k=E[s];try{j=new ActiveXObject(k)}catch(q){}if(j){E=[k];break}}if(!j)throw new Error("require.getXhr(): XMLHttpRequest not available");return j};if(!require.fetchText)require.fetchText=function(j,s){var k=require.getXhr();k.open("GET",j,true);k.onreadystatechange=function(){k.readyState===4&&s(k.responseText)};k.send(null)};define("require/text",{load:function(j,
s,k,q){var r=false,A=j.indexOf("."),t=j.substring(0,A),B=j.substring(A+1,j.length);A=B.indexOf("!");if(A!==-1){r=B.substring(A+1,B.length);r=r==="strip";B=B.substring(0,A)}s=s.nameToUrl(t,"."+B);require.fetchText(s,function(D){D=r?require.textStrip(D):D;if(q.isBuild&&q.inlineText)v[j]=D;k(D)})},write:function(j,s,k){if(s in v){var q=require.jsEscape(v[s]);k("define('"+j+"!"+s+"', function () { return '"+q+"';});\n")}}})})();
(function(){function E(k,q,r){q([k],function(A){r(function(){return A})})}function K(k){var q=k.currentTarget||k.srcElement,r;if(k.type==="load"||v.test(q.readyState)){k=q.getAttribute("data-requiremodule");s[k]=true;for(k=0;r=j[k];k++)if(s[r.name])E(r.name,r.req,r.onLoad);else break;k>0&&j.splice(0,k);setTimeout(function(){q.parentNode.removeChild(q)},15)}}var M=typeof document!=="undefined"&&typeof window!=="undefined"&&(document.createElement("script").async||window.opera&&Object.prototype.toString.call(window.opera)===
"[object Opera]"||"MozAppearance"in document.documentElement.style),v=/^(complete|loaded)$/,j=[],s={};define("require/order",{load:function(k,q,r,A){var t=q.nameToUrl(k,null);if(A.isBuild)E(k,q,r);else{require.s.skipAsync[t]=true;if(M)q([k],function(B){r(function(){return B})});else if(q.isDefined(k))q([k],function(B){r(function(){return B})});else{j.push({name:k,req:q,onLoad:r});require.attach(t,"",k,K,"script/cache")}}}})})();