Skip to content

Commit

Permalink
Untabification, and spaces cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phtrivier committed Aug 6, 2010
1 parent 15d32a6 commit ca0544e
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/js/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function Drawer() {
Drawer.prototype.load_image = function(dest, key, url, callback) {
var img = new Image();
img.onload = function() {
dest[key] = img;
callback();
dest[key] = img;
callback();
};
img.src = "../../data/images/png/" + url;
img.width = 32;
Expand All @@ -20,32 +20,32 @@ Drawer.prototype.load_image = function(dest, key, url, callback) {
Drawer.prototype.load_many_images = function (content, callback) {
var that = this;
var load_helper = function (index) {
if (index == content.length) {
callback();
} else {
var args = content[index];
that.load_image(args[0], args[1], args[2], function () {
load_helper(index+1);
});
}
if (index == content.length) {
callback();
} else {
var args = content[index];
that.load_image(args[0], args[1], args[2], function () {
load_helper(index+1);
});
}
};
load_helper(0);
};

Drawer.prototype.load_images = function (callback) {

var content = [ [this.cell_images, "cell_1", "cell_1.png"],
[this.cell_images, "cell_2", "cell_2.png"],
[this.cell_images, "cell_3", "cell_3.png"],
[this.path_images, "path_0", "path_0.png"],
[this.path_images, "path_1", "path_1.png"],
[this.path_images, "path_2", "path_2.png"],
[this.overlays, Move.SINGLE, "overlay_move_0.png"],
[this.overlays, Move.DOUBLE, "overlay_move_1.png"],
[this.overlays, Move.KNIGHT, "overlay_move_2.png"],
[this.images, "player", "player.png"],
[this.images, "forbiden", "banned_cell.png"]
];
[this.cell_images, "cell_2", "cell_2.png"],
[this.cell_images, "cell_3", "cell_3.png"],
[this.path_images, "path_0", "path_0.png"],
[this.path_images, "path_1", "path_1.png"],
[this.path_images, "path_2", "path_2.png"],
[this.overlays, Move.SINGLE, "overlay_move_0.png"],
[this.overlays, Move.DOUBLE, "overlay_move_1.png"],
[this.overlays, Move.KNIGHT, "overlay_move_2.png"],
[this.images, "player", "player.png"],
[this.images, "forbiden", "banned_cell.png"]
];

this.load_many_images(content, callback);

Expand All @@ -62,27 +62,27 @@ Drawer.prototype.draw_move_overlay = function (move_type, i , j) {
Drawer.prototype.draw_puzzle = function(puzzle, goal) {
var that = this;
puzzle.each_cells(function (i,j,cell) {
var cell_type = cell.type;
// Add a div to the main div
if (cell_type !== null) {
if (cell_type == Cell.WALKABLE || cell_type == Cell.IN) {
that.draw_cell_image(that.cell_images["cell_1"], i,j);
} else if (cell_type == Cell.OUT) {
that.draw_cell_image(that.cell_images["cell_2"], i,j);
}
if (cell.in_path) {
that.draw_cell_image(that.path_images["path_" + puzzle.current_move().move_type],i,j);
}
cell.draw_overlay(g_drawer, i, j);
}
var cell_type = cell.type;
// Add a div to the main div
if (cell_type !== null) {
if (cell_type == Cell.WALKABLE || cell_type == Cell.IN) {
that.draw_cell_image(that.cell_images["cell_1"], i,j);
} else if (cell_type == Cell.OUT) {
that.draw_cell_image(that.cell_images["cell_2"], i,j);
}
if (cell.in_path) {
that.draw_cell_image(that.path_images["path_" + puzzle.current_move().move_type],i,j);
}
cell.draw_overlay(g_drawer, i, j);
}
});

this.draw_cell_image(this.images["player"], puzzle.player.i, puzzle.player.j);

if (goal && (puzzle.is_forbiden(goal))) {
this.draw_cell_image(this.images["forbiden"], goal.i, goal.j);
this.draw_cell_image(this.images["forbiden"], goal.i, goal.j);
}

};

0 comments on commit ca0544e

Please sign in to comment.