mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-25 09:58:50 +01:00
add optional level_index parameter
This commit is contained in:
parent
396cefca7d
commit
2bd110a87b
2 changed files with 6 additions and 3 deletions
|
@ -51,7 +51,7 @@
|
|||
<script src="js/star.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
initialize_a_star( "#main" );
|
||||
initialize_a_star( "#main", 0 );
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function initialize_a_star( dom_container ) {
|
||||
function initialize_a_star( dom_container, level_index ) {
|
||||
// kinda enums
|
||||
var cell= { WALL: '#', BALL: '@', CUBE: 'H', VOID: ' ', GIFT: 'x' };
|
||||
var direction = { UP: 'u', DOWN: 'd', LEFT: 'l', RIGHT: 'r' };
|
||||
|
@ -329,7 +329,10 @@ function initialize_a_star( dom_container ) {
|
|||
}
|
||||
|
||||
////// MAIN (so to speak) //////
|
||||
state = load_level( 0 );
|
||||
state = load_level( ( level_index === undefined ) ? 0 :
|
||||
( level_index >= assets.levels.length ) ? assets.levels.length - 1 :
|
||||
( level_index < 0 ) ? 0 : level_index
|
||||
);
|
||||
|
||||
start_loop( );
|
||||
|
||||
|
|
Loading…
Reference in a new issue