diff --git a/css/star.css b/css/star.css index 639a5cf..c710693 100644 --- a/css/star.css +++ b/css/star.css @@ -1,12 +1,4 @@ .gstar{width:660px;height:180px} .gstar em{font-weight:bold} -.gstar #blackboard{width:320px;height:180px;background:#333;float:left} -.gstar #blackboard .starcell{width:20px;height:20px;display:block;float:left;text-align:center} -.gstar #blackboard .wall{color:#000} -.gstar #blackboard .ball{color:#99f} -.gstar #blackboard .cube{color:red} -.gstar #blackboard .ball_selected{color:#99f} -.gstar #blackboard .cube_selected{color:red} -.gstar #blackboard .gift{color:yellow} -.gstar #blackboard .void{} +.gstar #starboard{width:320px;height:180px;background:#333;float:left} .gstar aside{float:left;height:140px;width:130px;padding:20px;background:#ddd} diff --git a/css/star_HP48.css b/css/star_HP48.css deleted file mode 100644 index 884b664..0000000 --- a/css/star_HP48.css +++ /dev/null @@ -1,7 +0,0 @@ -.gstar #blackboard .wall{background-image:url(../themes/HP48/tex_wall.png);} -.gstar #blackboard .ball{background-image:url(../themes/HP48/tex_ball.png);} -.gstar #blackboard .cube{background-image:url(../themes/HP48/tex_cube.png);} -.gstar #blackboard .ball_selected{background-image:url(../themes/HP48/tex_ball_selected.png);} -.gstar #blackboard .cube_selected{background-image:url(../themes/HP48/tex_cube_selected.png);} -.gstar #blackboard .gift{background-image:url(../themes/HP48/tex_gift.png);} -.gstar #blackboard .void{background-image:url(../themes/HP48/tex_empty.png);} diff --git a/css/star_cyco001.css b/css/star_cyco001.css deleted file mode 100644 index 460ef43..0000000 --- a/css/star_cyco001.css +++ /dev/null @@ -1,7 +0,0 @@ -.gstar #blackboard .wall{background-image:url(../themes/cyco001/tex_wall.png);} -.gstar #blackboard .ball{background-image:url(../themes/cyco001/tex_ball.png);} -.gstar #blackboard .cube{background-image:url(../themes/cyco001/tex_cube.png);} -.gstar #blackboard .ball_selected{background-image:url(../themes/cyco001/tex_ball_selected.png);} -.gstar #blackboard .cube_selected{background-image:url(../themes/cyco001/tex_cube_selected.png);} -.gstar #blackboard .gift{background-image:url(../themes/cyco001/tex_gift.png);} -.gstar #blackboard .void{background-image:url(../themes/cyco001/tex_empty.png);} diff --git a/css/star_cyco002.css b/css/star_cyco002.css deleted file mode 100644 index 99d38b9..0000000 --- a/css/star_cyco002.css +++ /dev/null @@ -1,7 +0,0 @@ -.gstar #blackboard .wall{background-image:url(../themes/cyco002/tex_wall.png);} -.gstar #blackboard .ball{background-image:url(../themes/cyco002/tex_ball.png);} -.gstar #blackboard .cube{background-image:url(../themes/cyco002/tex_cube.png);} -.gstar #blackboard .ball_selected{background-image:url(../themes/cyco002/tex_ball_selected.png);} -.gstar #blackboard .cube_selected{background-image:url(../themes/cyco002/tex_cube_selected.png);} -.gstar #blackboard .gift{background-image:url(../themes/cyco002/tex_gift.png);} -.gstar #blackboard .void{background-image:url(../themes/cyco002/tex_empty.png);} diff --git a/css/star_inversed.css b/css/star_inversed.css deleted file mode 100644 index 43374a9..0000000 --- a/css/star_inversed.css +++ /dev/null @@ -1,7 +0,0 @@ -.gstar #blackboard .wall{background-image:url(../themes/inversed/tex_wall.png);} -.gstar #blackboard .ball{background-image:url(../themes/inversed/tex_ball.png);} -.gstar #blackboard .cube{background-image:url(../themes/inversed/tex_cube.png);} -.gstar #blackboard .ball_selected{background-image:url(../themes/inversed/tex_ball_selected.png);} -.gstar #blackboard .cube_selected{background-image:url(../themes/inversed/tex_cube_selected.png);} -.gstar #blackboard .gift{background-image:url(../themes/inversed/tex_gift.png);} -.gstar #blackboard .void{background-image:url(../themes/inversed/tex_empty.png);} diff --git a/js/star.js b/js/star.js index 7cfd9e0..21543a0 100644 --- a/js/star.js +++ b/js/star.js @@ -98,44 +98,25 @@ function won_or_not( state ) { return count_gifts( state ) === 0; } -function format_level( state, text ) { - function Replacer( conversionObject ) { - - var regexpStr = ''; - for ( var k in conversionObject ) { - regexpStr += ( regexpStr.length ? '|' : '' ) + k; - } - var regexpr = new RegExp( regexpStr, 'mig' ); // g: global, m:multi-line i: ignore case - return function(s) { - return s.replace( regexpr, function(str, p1, p2, offset, s) { - var a = conversionObject[ str ]; - return a == undefined ? str : a; - } ); - }; - } - - var substitutions = { - '#': '#', - 'x': 'x', - ' ': ' ', - 'H': 'H', - '@': '@' - }; - substitutions[ state.moving ] = substitutions[ state.moving ].replace( '">', '_selected">' ); - if ( text == false ) { - for ( var c in substitutions ) { - substitutions[ c ] = substitutions[ c ].replace( />., '><' ); - } - } - var myReplacer = Replacer( substitutions ); - return myReplacer( state.board ); -} function display_on_canvas( state, canvas_elt ) { + board_infos = {}; + board_infos.cell_dimensions = {}; + board_infos.cell_dimensions.width = 20; + board_infos.cell_dimensions.height = 20; var ctx= document.getElementById( canvas_elt ).getContext( '2d' ); for ( var i=0 ; i < LEVEL_HEIGHT ; i++ ) { for ( var j=0 ; j < LEVEL_WIDTH ; j++ ) { - ctx.translate( j * board_infos.cell_dimensions.width, i * board_infos.cell_dimensions.height ); - ctx.drawImage( sprites.ball, j * board_infos.cell_dimensions.width, i * board_infos.cell_dimensions.height ); + var c = get_cell( state, j, i ); + var sprite = "bla"; + switch( c ) { + case "@": sprite = ( state.moving == cell.BALL ) ? sprites.ball_selected : sprites.ball; break; + case "H": sprite = ( state.moving == cell.CUBE ) ? sprites.cube_selected : sprites.cube; break; + case "#": sprite = sprites.wall; break; + case "x": sprite = sprites.gift; break; + case " ": sprite = sprites.void; break; + } + ctx.drawImage( sprite, j * board_infos.cell_dimensions.width, i * board_infos.cell_dimensions.height, board_infos.cell_dimensions.width, board_infos.cell_dimensions.height + ); } } } @@ -156,7 +137,6 @@ function format_help( ) { } function display_level( state, elt ) { - $( elt + " .gstar #blackboard" ).html( format_level( state, false ) ); $( elt + " .gstar #infos" ).html( format_infos( state ) ); display_on_canvas( state, "starboard" ); } @@ -313,14 +293,14 @@ function start_loop( state, elt ) { function initialize_a_star( elt ) { var starhtml = '