diff --git a/star.js/index.html b/star.js/index.html index 8d943b5..21213a4 100644 --- a/star.js/index.html +++ b/star.js/index.html @@ -51,7 +51,7 @@ diff --git a/star.js/js/star.js b/star.js/js/star.js index 341a1a4..f184737 100644 --- a/star.js/js/star.js +++ b/star.js/js/star.js @@ -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( );