Skip to content

Commit

Permalink
Merge branch 'feature/levels' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
phtrivier committed Oct 4, 2010
2 parents e2d4293 + 07fbe93 commit 15eb468
Show file tree
Hide file tree
Showing 18 changed files with 289 additions and 123 deletions.
Binary file modified data/images/png/disabled_redo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/images/png/disabled_undo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/png/move_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/png/move_3_grayed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/png/overlay_move_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/png/path_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/images/png/redo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/images/png/undo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ a:active {text-decoration: none ; }
a:hover {text-decoration: underline; }

#footer {
font-size : small;
text-align : center;
}

Expand Down Expand Up @@ -131,7 +132,8 @@ a:hover {text-decoration: underline; }
color : white;
}


.unselected-chapter {
color : gray;
/* color : gray; */
}

1 change: 1 addition & 0 deletions src/css/in-game.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ a:hover {text-decoration: underline; }

#footer {
font-size : small;
text-align : center;
}

/* Undo / Redo buttons */
Expand Down
2 changes: 1 addition & 1 deletion src/html/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h4 id="level-preview-header" class="span-12 last"></h4>
</div>

<div id="footer" class="span-20 last prepend-top">
Copyright 2010 - <a href="mailto:[email protected]">Pierre-Henri Trivier</a>
Copyright (C) 2010 - <a href="mailto:[email protected]">Pierre-Henri Trivier</a>
</div>

</body>
Expand Down
4 changes: 2 additions & 2 deletions src/html/in-game.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ <h3 id="puzzle-title">...Veuillez patienter...</h3>
<div id="moves" class="span-16 prepend-top"></div>
</div>

<div id="footer" class="span-20 prepend-top">
Copyright (C) 2010 - Pierre-Henri Trivier
<div id="footer" class="span-20 last prepend-top">
Copyright (C) 2010 - <a href="mailto:[email protected]">Pierre-Henri Trivier</a>
</div>

</div>
Expand Down
2 changes: 2 additions & 0 deletions src/js/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ Drawer.prototype.load_images = function (callback) {
[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.path_images, "path_3", "path_3.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.overlays, Move.TRIPLE, "overlay_move_3.png"],
[this.images, "player", "player.png"],
[this.images, "forbiden", "banned_cell.png"]
];
Expand Down
81 changes: 60 additions & 21 deletions src/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ g_home_i18n = {
"welcome" : "Welcome to UBE",
"intro" : "Ube is a puzzle game, where you try to reach the exit with only a few moves available.",
"play.tutorial" : "Play tutorial",
"play.game" : "Play game (coming soon !)",
"play.game" : "Play game (work in progress !)",
"level.preview" : "Level preview",
"level.preview.stub" : "Click on a level name to display a preview",
"play" : "Play"},
Expand All @@ -13,34 +13,60 @@ g_home_i18n = {
"welcome": "Bienvenue dans UBE",
"intro" : "Ube est un casse-tête. Vous devez atteindre la sortie d'un labyrinthe, mais seuls certains mouvements sont possibles !",
"play.tutorial" : "Tutoriel",
"play.game" : "Jeu complet (c'est pour bientôt !)",
"play.game" : "Jeu (ça avance !)",
"level.preview" : "Aperçu du niveau",
"level.preview.stub" : "Cliquez sur le titre d'un niveau pour afficher un aperçu",
"play" : "Jouer" }
};

Home = function () {
Home = function (lg) {
this.drawer = new Drawer(16);
this.puzzle = null;
this.has_puzzle = false;
this.selected_chapter = null;
this.lg = lg;
}

Home.prototype.set_selected_chapter = function (chapter_id) {
if (this.selected_chapter != chapter_id) {
if (chapter_id == 0) {
this.load_tutorial_level_list();
} else {
this.load_game_level_list();
}
this.add_selected_class(chapter_id);
}
this.selected_chapter = chapter_id;
}

Home.prototype.toggle = function(selector, c1, c2) {
$(selector).removeClass(c1).addClass(c2);
}

Home.prototype.add_selected_class = function (chapter_id) {
this.toggle("#chapter_" + chapter_id, "unselected-chapter", "selected-chapter");
this.toggle("#chapter_" + chapter_id, "tab-header-unselected", "tab-header-selected");

this.toggle("#chapter_" + ((chapter_id+1) % 2), "selected-chapter", "unselected-chapter");
this.toggle("#chapter_" + ((chapter_id+1) % 2), "tab-header-selected", "tab-header-unselected" );
}

Home.prototype.puzzle_href = function (puzzle_id) {
return "in-game.html?puzzle_id=" + puzzle_id;
}

Home.prototype.append_i18n = function (selector, lg, key) {
$(selector).append(g_home_i18n[lg][key]);
Home.prototype.append_i18n = function (selector, key) {
$(selector).append(g_home_i18n[this.lg][key]);
}

Home.prototype.load_translated_text = function(lg) {
this.append_i18n('#welcome', lg, "welcome");
this.append_i18n('#intro', lg, "intro");
this.append_i18n('#chapter_0', lg, "play.tutorial");
this.append_i18n('#chapter_1', lg, "play.game");
this.append_i18n("#levels-header", lg, "level.choose");
this.append_i18n("#level-preview-header", lg, "level.preview");
this.append_i18n("#preview-stub", lg, "level.preview.stub");
Home.prototype.load_translated_text = function() {
this.append_i18n('#welcome', "welcome");
this.append_i18n('#intro', "intro");
this.append_i18n('#chapter_0', "play.tutorial");
this.append_i18n('#chapter_1', "play.game");
this.append_i18n("#levels-header", "level.choose");
this.append_i18n("#level-preview-header", "level.preview");
this.append_i18n("#preview-stub", "level.preview.stub");

$('#levels-header').mousedown(function (event) {
if (event.preventDefault) {
Expand All @@ -64,20 +90,28 @@ Home.prototype.on_level_selected = function(li, level_index) {
var play_div = $("<div id='play' class='button span-4 last'><div>");
play_div.append("<a id='play_link'></a>");
$("#preview-footer").append(play_div);
this.append_i18n("#play_link", get_lg(), "play");
this.append_i18n("#play_link", "play");
this.has_puzzle = true;
}

$("#play_link").attr("href", this.puzzle_href(level_index));
}

Home.prototype.load_tutorial_level_list = function(lg) {
Home.prototype.load_tutorial_level_list = function() {
this.load_level_list(0,7, this.lg);
}

Home.prototype.load_game_level_list = function() {
this.load_level_list(7,14, this.lg);
}

Home.prototype.load_level_list = function(start, finish) {
$("#levels").empty();
var that = this;
for (var i = 0 ; i < 8 ; i++) {
for (var i = start ; i < finish ; i++) {

var levelDiv = $("<li class='level' id='level_link_" + i + "'></li>");
levelDiv.append(PUZZLE_STRUCTS[i].title[lg]);
levelDiv.append(PUZZLE_STRUCTS[i].title[this.lg]);

levelDiv.hover(function (event) {
if (!$(this).hasClass('selected-level')) {
Expand Down Expand Up @@ -105,11 +139,16 @@ $(document).ready(function(){

new CanvasChecker().check_canvas();

var h = new Home
var h = new Home(get_lg());
h.drawer.load_images(function () {
var lg = get_lg();
h.load_translated_text(lg);
h.load_tutorial_level_list(lg);
h.load_translated_text();
h.set_selected_chapter(0);
$("#chapter_0").click(function (event) {
h.set_selected_chapter(0);
});
$("#chapter_1").click(function (event) {
h.set_selected_chapter(1);
});
});

});
55 changes: 32 additions & 23 deletions src/js/jsube.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,44 @@ function prevent_double_click(elem) {
});
}

function set_title(puzzle, puzzle_id) {
// Put title of the puzzle
$("#puzzle-title").empty();
$("#puzzle-title").append(puzzle.get_title(g_lang));
document.title = "Ube - " + puzzle.get_title(g_lang);
}

function set_links(puzzle_id) {
// Put text in links
$("#link_previous").append(i18n[g_lang]["puzzle.previous"]);
$("#link_next").append(i18n[g_lang]["puzzle.next"]);
$("#link_home").append(i18n[g_lang]["puzzle.home"]);

// Load links
if (puzzle_id > 0) {
$("#link_previous").attr("href", puzzle_href(puzzle_id - 1));
} else {
$("#link_previous").css("visibility", "hidden");
}
if (puzzle_id < (PUZZLE_STRUCTS.length - 1)) {
$("#link_next").attr("href", puzzle_href(puzzle_id + 1));
} else {
$("#link_next").css("display", "none");
}
}

function load_puzzle() {
var res = null;
var puzzle_id = parseInt($.url.param("puzzle_id"));
if (puzzle_id < PUZZLE_STRUCTS.length) {
var puzzle_struct = PUZZLE_STRUCTS[puzzle_id];
res = new Puzzle(puzzle_struct);

// Put title of the puzzle
$("#puzzle-title").empty();
$("#puzzle-title").append(res.get_title(g_lang));
document.title = "Ube - " + res.get_title(g_lang);

// Put text in links
$("#link_previous").append(i18n[g_lang]["puzzle.previous"]);
$("#link_next").append(i18n[g_lang]["puzzle.next"]);
$("#link_home").append(i18n[g_lang]["puzzle.home"]);

// Load links
if (puzzle_id > 0) {
$("#link_previous").attr("href", puzzle_href(puzzle_id - 1));
} else {
$("#link_previous").css("visibility", "hidden");
}
if (puzzle_id < (PUZZLE_STRUCTS.length - 1)) {
$("#link_next").attr("href", puzzle_href(puzzle_id + 1));
} else {
$("#link_next").css("display", "none");
}

set_title(res);
set_links(puzzle_id);
} else if (EASTER_EGGS[puzzle_id] != null) {
// Ok, I want to keep the easter eggs for later ... and am I pretty sure someone will check ...
res = new Puzzle(EASTER_EGGS[puzzle_id]);
set_title(res);
}
return res;
}
Expand Down
14 changes: 14 additions & 0 deletions src/js/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function Move(type) {
Move.SINGLE = 0;
Move.DOUBLE = 1;
Move.KNIGHT = 2;
Move.TRIPLE = 3;

Move.moves = {};

Expand Down Expand Up @@ -43,6 +44,19 @@ Move.moves[Move.KNIGHT] = function (node) {
return res
};


Move.moves[Move.TRIPLE] = function (node) {
var res = [];
// if (node.depth <= 1) {
res = [ { i : node.i + 3, j : node.j },
{ i : node.i -3, j : node.j },
{ i : node.i, j : node.j + 3},
{ i : node.i, j : node.j -3} ];
// }
return res;
};


Move.sp = function (move_type, node) {
return Move.moves[move_type](node);
};
Expand Down
3 changes: 3 additions & 0 deletions src/js/puzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Puzzle.prototype.load_cells = function (rows) {
case 'K':
cell = new MoveCell(Move.KNIGHT);
break;
case 'T' :
cell = new MoveCell(Move.TRIPLE);
break;
}
that.cells[i][j] = cell;
});
Expand Down
Loading

0 comments on commit 15eb468

Please sign in to comment.