var engine = null;
var map = null;

function init()
{
    engine = new Sparrow.Engine( "canvas" );
    engine.canvas.fillBrowserWindow( true );
    engine.b_drawDebugInfo = false;
    engine.onKeyDown = ( event ) => {
        map.car.move( event );
    };
    engine.onKeyUp = ( event ) => {
        map.car.move( event );
    };

    map = new Map( engine );
    var ui = new UI( engine , map );
    map.ui = ui;

    engine.update = function( dt )
    {
        if ( map.state == Map.STATE_GAME )
        {
            map.update( dt );
        }
    }

    engine.draw = function()
    {
        engine.defaultShader2D.use();
        // engine.restoreDefaultUniforms();
        map.draw();
        ui.draw();
    }

    engine.start();
}