From 2bd110a87b45f9f472d8c25c9530993c53cf1c68 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 14 Jul 2011 13:10:52 +0200 Subject: [PATCH] add optional level_index parameter --- star.js/index.html | 2 +- star.js/js/star.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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( );