Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
izb committed May 22, 2013
1 parent 0a0b1ec commit 0b37b14
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 136 deletions.
16 changes: 8 additions & 8 deletions src/ai/proximity-tracker.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ define(function() {
r = Math.ceil(r/this.cellw); r = Math.ceil(r/this.cellw);


if(this.candidateCache.hasOwnProperty(r)) { if(this.candidateCache.hasOwnProperty(r)) {
var cache = this.candidateCache[r]; var cache = this.candidateCache[r];
this.certains = cache.certains; this.certains = cache.certains;
this.uncertains = cache.uncertains; this.uncertains = cache.uncertains;
return; return;
} }
Expand All @@ -89,7 +89,7 @@ define(function() {
this.uncertains = [-s-1,-s,-s+1,-1,0,1,s-1,s,s+1]; this.uncertains = [-s-1,-s,-s+1,-1,0,1,s-1,s,s+1];


} else { } else {
this.certains = []; this.certains = [];
this.uncertains = []; this.uncertains = [];


var rmax = (r+1)*(r+1); var rmax = (r+1)*(r+1);
Expand Down Expand Up @@ -145,7 +145,7 @@ define(function() {


var cx = (x/this.cellw)|0; var cx = (x/this.cellw)|0;
var cy = (y/this.cellh)|0; var cy = (y/this.cellh)|0;
var c = cy*this.span+cx; var c = cy*this.span+cx;


/* Cells that are certain to be within the radius are easy */ /* Cells that are certain to be within the radius are easy */
for (i = this.certains.length - 1; i >= 0; i--) { for (i = this.certains.length - 1; i >= 0; i--) {
Expand Down Expand Up @@ -176,7 +176,7 @@ define(function() {
cell = this.cells[oc]; cell = this.cells[oc];
if (cell!==undefined) { if (cell!==undefined) {
for (j = cell.sprites.length - 1; j >= 0; j--) { for (j = cell.sprites.length - 1; j >= 0; j--) {
s = cell.sprites[j]; s = cell.sprites[j];
dx = x-s.x; dx = x-s.x;
dy = (y-s.y)*2; dy = (y-s.y)*2;
s.tmpDist2=(dx*dx+dy*dy); s.tmpDist2=(dx*dx+dy*dy);
Expand Down Expand Up @@ -216,9 +216,9 @@ define(function() {
ProximityTracker.prototype.track = function(sprite) { ProximityTracker.prototype.track = function(sprite) {
var pd = sprite.proximityData[this.id]; var pd = sprite.proximityData[this.id];


var x = (sprite.x/this.cellw)|0; var x = (sprite.x/this.cellw)|0;
var y = (sprite.y/this.cellh)|0; var y = (sprite.y/this.cellh)|0;
var c = y*this.span+x; var c = y*this.span+x;


if(c!==pd.cell) { if(c!==pd.cell) {
removeFromItsCell.call(this, sprite); removeFromItsCell.call(this, sprite);
Expand Down
178 changes: 88 additions & 90 deletions src/input/keyboard.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,104 +22,104 @@ define(function() {
*/ */
this.keymap = { this.keymap = {
backspace: 8, backspace: 8,
tab: 9, tab : 9,
enter: 13, enter : 13,
pause: 19, pause : 19,
capsLock: 20, capsLock : 20,
escape: 27, escape : 27,
space: 32, space : 32,
pageUp: 33, pageUp : 33,
pageDown: 34, pageDown : 34,
end: 35, end : 35,
home: 36, home : 36,
left: 37, left : 37,
up: 38, up : 38,
right: 39, right : 39,
down: 40, down : 40,
ins: 45, ins : 45,
del: 46, del : 46,


/* Main keyboard */ /* Main keyboard */
plus: 187, plus : 187,
comma: 188, comma : 188,
minus: 189, minus : 189,
period: 190, period : 190,


shift: 16, shift : 16,
ctrl: 17, ctrl : 17,
alt: 18, alt : 18,


/* top row */ /* top row */
zero: 48, zero : 48,
one: 49, one : 49,
two: 50, two : 50,
three: 51, three : 51,
four: 52, four : 52,
five: 53, five : 53,
six: 54, six : 54,
seven: 55, seven : 55,
eight: 56, eight : 56,
nine: 57, nine : 57,


a: 65, a : 65,
b: 66, b : 66,
c: 67, c : 67,
d: 68, d : 68,
e: 69, e : 69,
f: 70, f : 70,
g: 71, g : 71,
h: 72, h : 72,
i: 73, i : 73,
j: 74, j : 74,
k: 75, k : 75,
l: 76, l : 76,
m: 77, m : 77,
n: 78, n : 78,
o: 79, o : 79,
p: 80, p : 80,
q: 81, q : 81,
r: 82, r : 82,
s: 83, s : 83,
t: 84, t : 84,
u: 85, u : 85,
v: 86, v : 86,
w: 87, w : 87,
x: 88, x : 88,
y: 89, y : 89,
z: 90, z : 90,


/* Number pad */ /* Number pad */
num0: 96, num0 : 96,
num1: 97, num1 : 97,
num2: 98, num2 : 98,
num3: 99, num3 : 99,
num4: 100, num4 : 100,
num5: 101, num5 : 101,
num6: 102, num6 : 102,
num7: 103, num7 : 103,
num8: 104, num8 : 104,
num9: 105, num9 : 105,


/* More number pad */ /* More number pad */
multiply: 106, multiply : 106,
add: 107, add : 107,
substract: 109, substract: 109,
decimal: 110, decimal : 110,
divide: 111, divide : 111,


/* Function keys */ /* Function keys */
F1: 112, F1 : 112,
F2: 113, F2 : 113,
F3: 114, F3 : 114,
F4: 115, F4 : 115,
F5: 116, F5 : 116,
F6: 117, F6 : 117,
F7: 118, F7 : 118,
F8: 119, F8 : 119,
F9: 120, F9 : 120,
F10: 121, F10 : 121,
F11: 122, F11 : 122,
F12: 123 F12 : 123
}; };


this.actions = []; this.actions = [];
Expand All @@ -140,8 +140,7 @@ define(function() {


var keydown = function(e) { var keydown = function(e) {
var tag = e.target.tagName; var tag = e.target.tagName;
if (e.type !== 'keydown' || tag === 'INPUT' || tag === 'TEXTAREA') if (e.type !== 'keydown' || tag === 'INPUT' || tag === 'TEXTAREA') {
{
return; return;
} }
e.preventDefault(); e.preventDefault();
Expand All @@ -154,8 +153,7 @@ define(function() {
}; };


var keyup = function(e) { var keyup = function(e) {
if (e.type !== 'keyup') if (e.type !== 'keyup') {
{
return; return;
} }
e.preventDefault(); e.preventDefault();
Expand Down
10 changes: 5 additions & 5 deletions src/input/mouse.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ define(function() {
this.y = 0; this.y = 0;


this.inputmap = { this.inputmap = {
mouse1: -1, mouse1 : -1,
mouse2: -3, mouse2 : -3,
wheelUp: -4, wheelUp : -4,
wheelDown: -5 wheelDown: -5
}; };


var mousemoved = function(e) { var mousemoved = function(e) {
var rect = canvas.getBoundingClientRect(); var rect = canvas.getBoundingClientRect();
_this.x = e.clientX - rect.left; _this.x = e.clientX - rect.left;
_this.y = e.clientY - rect.top; _this.y = e.clientY - rect.top;
}; };


canvas.addEventListener('mousemove', mousemoved, false); canvas.addEventListener('mousemove', mousemoved, false);
Expand Down
32 changes: 16 additions & 16 deletions src/map/staggered-isometric.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -255,17 +255,17 @@ define(['map/tile', 'util/bitmap', 'util/debug', 'util/js'], function(Tile, Bitm
*/ */
StaggeredIsometric.prototype.drawDebugRegions = function(ctx, props) { StaggeredIsometric.prototype.drawDebugRegions = function(ctx, props) {


var map = this.data; var map = this.data;
var l, layerEndY, layerEndX, r, x, y, stagger; var l, layerEndY, layerEndX, r, x, y, stagger;


var xstep = map.tilewidth; var xstep = map.tilewidth;
var ystep = map.tileheight / 2; var ystep = map.tileheight / 2;


var starty = Math.floor((this.yoffset-ystep) / ystep); var starty = Math.floor((this.yoffset-ystep) / ystep);
var endy = Math.floor((this.yoffset+this.clientHeight-ystep+this.maxYOverdraw) / ystep)+1; var endy = Math.floor((this.yoffset+this.clientHeight-ystep+this.maxYOverdraw) / ystep)+1;


var startx = Math.floor((this.xoffset+this.clientWidth -1 ) / xstep); var startx = Math.floor((this.xoffset+this.clientWidth -1 ) / xstep);
var endx = Math.floor((this.xoffset-xstep/2-this.maxXOverdraw) / xstep); var endx = Math.floor((this.xoffset-xstep/2-this.maxXOverdraw) / xstep);


l = map.layers[0]; l = map.layers[0];


Expand Down Expand Up @@ -399,8 +399,8 @@ define(['map/tile', 'util/bitmap', 'util/debug', 'util/js'], function(Tile, Bitm


var map = this.data; var map = this.data;


var tw = map.tilewidth; var tw = map.tilewidth;
var th = map.tileheight; var th = map.tileheight;


x=x|0; x=x|0;
y=y|0; y=y|0;
Expand Down Expand Up @@ -571,7 +571,7 @@ define(['map/tile', 'util/bitmap', 'util/debug', 'util/js'], function(Tile, Bitm
*/ */
StaggeredIsometric.prototype.updateLayers = function(now) { StaggeredIsometric.prototype.updateLayers = function(now) {
var epoch = +new Date(); var epoch = +new Date();
var map = this.data; var map = this.data;
for (var i = 0; i < map.layers.length; i++) { for (var i = 0; i < map.layers.length; i++) {
var l = map.layers[i]; var l = map.layers[i];
if (l.hasOwnProperty('update')) { if (l.hasOwnProperty('update')) {
Expand Down Expand Up @@ -606,11 +606,11 @@ define(['map/tile', 'util/bitmap', 'util/debug', 'util/js'], function(Tile, Bitm
* @private * @private
*/ */
StaggeredIsometric.prototype.onResize = function(w, h) { StaggeredIsometric.prototype.onResize = function(w, h) {
this.clientWidth = w; this.clientWidth = w;
this.clientHeight = h; this.clientHeight = h;


this.maxxoffset = this.data.width * this.data.tilewidth - this.clientWidth - 1; this.maxxoffset = this.data.width * this.data.tilewidth - this.clientWidth - 1;
this.maxyoffset = this.data.height * (this.data.tileheight/2) - this.clientHeight - 1; this.maxyoffset = this.data.height * (this.data.tileheight/2) - this.clientHeight - 1;
}; };




Expand All @@ -620,18 +620,18 @@ define(['map/tile', 'util/bitmap', 'util/debug', 'util/js'], function(Tile, Bitm
*/ */
StaggeredIsometric.prototype.drawWorld = function(ctx, now, sprites) { StaggeredIsometric.prototype.drawWorld = function(ctx, now, sprites) {


var map = this.data; var map = this.data;


var epoch; var epoch;


var xstep = map.tilewidth; var xstep = map.tilewidth;
var ystep = map.tileheight / 2; var ystep = map.tileheight / 2;


var starty = Math.floor((this.yoffset-ystep) / ystep); var starty = Math.floor((this.yoffset-ystep) / ystep);
var endy = Math.floor((this.yoffset+this.clientHeight-ystep+this.maxYOverdraw) / ystep)+1; var endy = Math.floor((this.yoffset+this.clientHeight-ystep+this.maxYOverdraw) / ystep)+1;


var startx = Math.floor((this.xoffset+this.clientWidth -1 ) / xstep); var startx = Math.floor((this.xoffset+this.clientWidth -1 ) / xstep);
var endx = Math.floor((this.xoffset-xstep/2-this.maxXOverdraw) / xstep); var endx = Math.floor((this.xoffset-xstep/2-this.maxXOverdraw) / xstep);


epoch = +new Date(); epoch = +new Date();
/* Sort sprites first by y-axis, then by height, then creation order */ /* Sort sprites first by y-axis, then by height, then creation order */
Expand Down
16 changes: 8 additions & 8 deletions src/map/tile.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ define(['util/uid', 'util/js'], function(uid, js) {
* the defaults. * the defaults.
*/ */
function Tile(img, x, y, w, h, xoverdraw, yoverdraw, defaultProps, properties) { function Tile(img, x, y, w, h, xoverdraw, yoverdraw, defaultProps, properties) {
this.img = img; this.img = img;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.w = w; this.w = w;
this.h = h; this.h = h;
this.xoverdraw = xoverdraw; this.xoverdraw = xoverdraw;
this.yoverdraw = yoverdraw; this.yoverdraw = yoverdraw;
this.defaultProps = defaultProps||{}; this.defaultProps = defaultProps||{};
this.properties = properties||{}; this.properties = properties||{};
} }


/** /**
Expand Down
Loading

0 comments on commit 0b37b14

Please sign in to comment.