diff --git a/star.js/js/star.js b/star.js/js/star.js index 3b79175..93629ef 100644 --- a/star.js/js/star.js +++ b/star.js/js/star.js @@ -1,4 +1,4 @@ -let initialize_a_star = function( dom_container, level_index, theme ) { +let initialize_a_star = ( dom_container, level_index, theme ) => { // kinda enums let cell = { WALL: '#', BALL: '@', CUBE: 'H', EMPTY: ' ', GIFT: 'x' } let direction = { UP: 38, DOWN: 40, LEFT: 37, RIGHT: 39 } @@ -34,7 +34,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { } ////// FUNCTIONS ////// - let count_gifts = function() { + let count_gifts = () => { let n = 0 for ( let i = level_infos.height * level_infos.width ; i-- ; ) { if ( state.board[ i ] == cell.GIFT ) { @@ -44,7 +44,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { return n } - let get_pos = function( actor ) { + let get_pos = ( actor ) => { let p = state.board.indexOf( actor, state.board ) let pos = [] pos[ 1 ] = Math.floor( p / level_infos.width ) /* y */ @@ -53,24 +53,24 @@ let initialize_a_star = function( dom_container, level_index, theme ) { return pos } - let get_cell = function( x, y ) { + let get_cell = ( x, y ) => { return state.board[ x + ( y * level_infos.width ) ] } - let set_cell = function( x, y, value ) { + let set_cell = ( x, y, value ) => { let p = x + ( y * level_infos.width ) state.board = [ state.board.substring( 0, p ), value, state.board.substring( p+1, state.board.length ) ].join( '' ) } - let switch_actor = function() { + let switch_actor = () => { state.moving = ( state.moving == cell.BALL ) ? cell.CUBE : cell.BALL } - let won_or_not = function() { + let won_or_not = () => { return count_gifts() === 0 } - let load_level = function( index ) { + let load_level = ( index ) => { return( { moving: cell.BALL, distance_travelled: 0, level: index, @@ -78,7 +78,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { it_s_over: false } ) } - let make_a_move = function( where ) { + let make_a_move = ( where ) => { let motion = [ 0, 0 ] let item_coord = get_pos( state.moving ) @@ -129,7 +129,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { } ////// HTML/Canvas version specific functions - let load_sprites = function( theme ) { + let load_sprites = ( theme ) => { assets.sprites = { } assets.sprites.ball = new Image() assets.sprites.ball.src = "themes/" + theme + "/tex_ball.png" @@ -147,7 +147,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { assets.sprites.gift.src = "themes/" + theme + "/tex_gift.png" } - let draw_cell = function( sprite, x, y ) { + let draw_cell = ( sprite, x, y ) => { DOM_infos.canvas.context.drawImage( sprite, x * level_infos.cell.width, y * level_infos.cell.height, @@ -155,7 +155,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { level_infos.cell.height ) } - let display_switch_actor = function() { + let display_switch_actor = () => { let ball_pos = get_pos( cell.BALL ) let cube_pos = get_pos( cell.CUBE ) @@ -165,7 +165,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { draw_cell( ( state.moving == cell.CUBE ) ? assets.sprites.cube_selected : assets.sprites.cube, cube_pos[ 0 ], cube_pos[ 1 ] ) } - let full_display_on_canvas = function() { + let full_display_on_canvas = () => { for ( let i=0 ; i < level_infos.height ; i++ ) { for ( let j=0 ; j < level_infos.width ; j++ ) { let c = get_cell( j, i ) @@ -190,7 +190,7 @@ let initialize_a_star = function( dom_container, level_index, theme ) { } } - let update_infos = function() { + let update_infos = () => { let infos = "