//-----------------------------------------
//マップ-定義
//-----------------------------------------
MapFlg = true;
//方向定義
var add_adv = 0;
var gl_adv_n = add_adv++;//北
var gl_adv_s = add_adv++;//南
var gl_adv_e = add_adv++;//東
var gl_adv_w = add_adv++;//西
//進行可能方向定数
var add_passible = 0;
var gl_pass_n = add_passible++;
var gl_pass_s = add_passible++;
var gl_pass_e = add_passible++;
var gl_pass_w = add_passible++;
var gl_pass_ns = add_passible++;
var gl_pass_we = add_passible++;
var gl_pass_nw = add_passible++;
var gl_pass_wn = add_passible++;
var gl_pass_se = add_passible++;
var gl_pass_es = add_passible++;
var gl_pass_nsew = add_passible++;
var gl_pass_nsw = add_passible++;
var gl_pass_nse = add_passible++;
var gl_pass_sew = add_passible++;
var gl_pass_new = add_passible++;
var gl_pass_none = add_passible++;
//進行可能方向実態
/*
gl_map_nw
gl_map_wn
gl_map_se
gl_map_es
*/
var gl_pass_data = [
	//北,南,東,西
	[0,1,0,0],//gl_pass_n
	[1,0,0,0],//gl_pass_s
	[0,0,0,1],//gl_pass_e
	[0,0,1,0],//gl_pass_w
	[1,1,0,0],//gl_pass_ns
	[0,0,1,1],//gl_pass_we
	[0,1,0,1],//gl_pass_nw
	[1,0,0,1],//gl_pass_wn
	[1,0,1,0],//gl_pass_se
	[0,1,1,0],//gl_pass_es
	[1,1,1,1],//gl_pass_nsew
	[1,1,0,1],//gl_pass_nsw
	[1,1,1,0],//gl_pass_nse
	[0,1,1,1],//gl_pass_sew
	[1,0,1,1],//gl_pass_new
	[0,0,0,0],//gl_pass_none
];
//マップ部品
var add_map_part = 0;
var gl_map_straight_v = add_map_part++;
var gl_map_straight_h = add_map_part++;
var gl_map_cross = add_map_part++;
var gl_map_straight_p_r = add_map_part++;
var gl_map_straight_p_l = add_map_part++;
var gl_map_nw = add_map_part++;
var gl_map_wn = add_map_part++;
var gl_map_se = add_map_part++;
var gl_map_es = add_map_part++;
var gl_map_t_jiro_n = add_map_part++;
var gl_map_t_jiro_s = add_map_part++;
var gl_map_stop = add_map_part++;
var gl_map_squear = add_map_part++;
var gl_map_none = add_map_part++;
//進行可能方向実態
var gl_map_part = [
	//北,南,東,西
	[gl_pass_ns,gl_pass_ns,gl_pass_none,gl_pass_none],//gl_map_straight_v
	[gl_pass_none,gl_pass_none,gl_pass_we,gl_pass_we],//gl_map_straight_h
	[gl_pass_nsew,gl_pass_nsew,gl_pass_nsew,gl_pass_nsew],//gl_map_cross
	[gl_pass_nsw,gl_pass_nsw,gl_pass_nsw,gl_pass_nsw],//gl_map_straight_p_r
	[gl_pass_nse,gl_pass_nse,gl_pass_nse,gl_pass_nse],//gl_map_straight_p_l
	[gl_pass_nw,gl_pass_nw,gl_pass_nw,gl_pass_nw],//gl_map_nw
	[gl_pass_wn,gl_pass_wn,gl_pass_wn,gl_pass_wn],//gl_map_wn
	[gl_pass_se,gl_pass_se,gl_pass_se,gl_pass_se],//gl_map_se
	[gl_pass_es,gl_pass_es,gl_pass_es,gl_pass_es],//gl_map_es
	[gl_pass_sew,gl_pass_none,gl_pass_sew,gl_pass_sew],//gl_map_t_jiro_n
	[gl_pass_none,gl_pass_new,gl_pass_new,gl_pass_new],//gl_map_t_jiro_s
	[gl_pass_n,gl_pass_s,gl_pass_e,gl_pass_w],//gl_map_stop
	[gl_pass_n,gl_pass_s,gl_pass_e,gl_pass_w],//gl_map_squear
	[gl_pass_none,gl_pass_none,gl_pass_none,gl_pass_none],//gl_map_none
];
//マップデータ（9×7）
var gl_map_data = [
[],
];
//遺跡1エリア
var gl_map_data2 = [
[gl_map_stop,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_n,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_stop,gl_map_t_jiro_n,gl_map_stop],
[gl_map_wn,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_stop,gl_map_se,gl_map_nw,gl_map_straight_h,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_cross,gl_map_es,gl_map_wn,gl_map_straight_p_l,gl_map_straight_v],
[gl_map_stop,gl_map_t_jiro_n,gl_map_cross,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_h,gl_map_straight_h,gl_map_cross,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_es,gl_map_wn,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_p_r,gl_map_se,gl_map_none,gl_map_straight_v,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_nw,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_cross,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_se],
[gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_t_jiro_n,gl_map_se,gl_map_none],
[gl_map_straight_p_r,gl_map_se,gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_nw,gl_map_cross,gl_map_es,gl_map_straight_v,gl_map_squear,gl_map_stop,gl_map_t_jiro_s,gl_map_es,gl_map_straight_p_r,gl_map_straight_h,gl_map_es],
[gl_map_straight_v,gl_map_stop,gl_map_t_jiro_s,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_stop,gl_map_cross,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_wn,gl_map_t_jiro_n,gl_map_es,gl_map_wn,gl_map_se,gl_map_nw,gl_map_se],
[gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_cross,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_none,gl_map_wn,gl_map_es],
[gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_cross,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_wn,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_es,gl_map_nw,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_squear,gl_map_cross,gl_map_cross,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_cross,gl_map_t_jiro_s,gl_map_cross,gl_map_cross,gl_map_straight_h,gl_map_straight_h,gl_map_cross,gl_map_se,gl_map_straight_v,gl_map_straight_p_r,gl_map_stop],
[gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_se,gl_map_straight_p_r,gl_map_cross,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_cross,gl_map_t_jiro_s,gl_map_se],
[gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_straight_p_r,gl_map_se,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_t_jiro_n,gl_map_stop,gl_map_t_jiro_s,gl_map_se,gl_map_stop,gl_map_es],
[gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_cross,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_nw,gl_map_t_jiro_s,gl_map_cross,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_stop],
[gl_map_wn,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_cross,gl_map_es,gl_map_wn,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_es,gl_map_straight_v,gl_map_straight_p_r,gl_map_es,gl_map_wn,gl_map_es],
[gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_cross,gl_map_se,gl_map_stop,gl_map_straight_p_l,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_se,gl_map_straight_v,gl_map_nw,gl_map_se],
[gl_map_straight_v,gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_es,gl_map_straight_p_r,gl_map_straight_h,gl_map_se,gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_none],
[gl_map_wn,gl_map_se,gl_map_nw,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_cross,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_se,gl_map_straight_p_r,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_s,gl_map_se,gl_map_wn,gl_map_es],
[gl_map_stop,gl_map_es,gl_map_straight_p_r,gl_map_straight_h,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_s,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_es,gl_map_straight_v,gl_map_straight_p_r,gl_map_cross,gl_map_t_jiro_n,gl_map_straight_h,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_p_r,gl_map_cross,gl_map_es,gl_map_stop,gl_map_straight_p_l,gl_map_stop,gl_map_es,gl_map_squear,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_straight_h,gl_map_cross,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l,gl_map_stop,gl_map_se,gl_map_straight_v],
[gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_stop,gl_map_none,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_h,gl_map_se,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_se],
];
//森・第2エリア
var gl_map_data3 = [
[gl_map_stop,gl_map_t_jiro_n,gl_map_straight_h,gl_map_es,gl_map_nw,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_es,gl_map_nw,gl_map_t_jiro_n,gl_map_es],
[gl_map_wn,gl_map_se,gl_map_nw,gl_map_t_jiro_s,gl_map_se,gl_map_straight_v,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_stop,gl_map_es,gl_map_nw,gl_map_se,gl_map_wn,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_squear,gl_map_straight_v],
[gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_squear,gl_map_es,gl_map_straight_p_r,gl_map_cross,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_straight_h,gl_map_es,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_se,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_se,gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_p_l,gl_map_wn,gl_map_stop,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_se,gl_map_straight_v],
[gl_map_straight_p_r,gl_map_straight_p_l,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_straight_p_r,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_cross,gl_map_t_jiro_n,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_cross,gl_map_se,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_stop,gl_map_se,gl_map_wn,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_cross,gl_map_straight_p_l,gl_map_stop,gl_map_se,gl_map_stop,gl_map_straight_p_l,gl_map_wn,gl_map_straight_h,gl_map_se,gl_map_straight_v],
[gl_map_straight_p_r,gl_map_es,gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_se,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v],
[gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v,gl_map_straight_p_r,gl_map_cross,gl_map_t_jiro_s,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_p_r,gl_map_se,gl_map_straight_v],
[gl_map_stop,gl_map_es,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_se,gl_map_straight_p_r,gl_map_cross,gl_map_cross,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_straight_v,gl_map_nw,gl_map_straight_h,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_n,gl_map_cross,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_cross,gl_map_t_jiro_n,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_v,gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_se,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_s,gl_map_straight_h,gl_map_se,gl_map_straight_p_r,gl_map_es,gl_map_wn,gl_map_es,gl_map_stop,gl_map_se,gl_map_straight_p_r,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_squear,gl_map_cross,gl_map_stop,gl_map_none,gl_map_stop,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_se,gl_map_straight_v],
[gl_map_wn,gl_map_se,gl_map_straight_p_r,gl_map_straight_p_l,gl_map_stop,gl_map_se,gl_map_straight_p_r,gl_map_cross,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_straight_v,gl_map_squear,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_straight_p_l,gl_map_wn,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_cross,gl_map_cross,gl_map_se,gl_map_none,gl_map_straight_p_r,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_se,gl_map_none,gl_map_stop,gl_map_straight_p_l],
[gl_map_wn,gl_map_es,gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_t_jiro_s,gl_map_cross,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_straight_v],
[gl_map_stop,gl_map_se,gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_straight_h,gl_map_es,gl_map_straight_p_r,gl_map_se,gl_map_straight_p_r,gl_map_cross,gl_map_es,gl_map_stop,gl_map_straight_p_l,gl_map_nw,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v],
[gl_map_straight_p_r,gl_map_straight_h,gl_map_cross,gl_map_es,gl_map_wn,gl_map_straight_h,gl_map_se,gl_map_straight_p_r,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_none,gl_map_wn,gl_map_se,gl_map_nw,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v],
[gl_map_wn,gl_map_es,gl_map_straight_p_r,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_se,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v],
[gl_map_stop,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_se,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_none,gl_map_wn,gl_map_se,gl_map_nw,gl_map_se,gl_map_straight_p_r,gl_map_se,gl_map_straight_v],
[gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_t_jiro_s,gl_map_se,gl_map_stop,gl_map_se,gl_map_stop,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_se],
];
//森・第3エリア
var gl_map_data4 = [
[gl_map_nw,gl_map_t_jiro_n,gl_map_es,gl_map_nw,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_n,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_stop],
[gl_map_squear,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_se,gl_map_straight_v,gl_map_nw,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_stop,gl_map_se,gl_map_wn,gl_map_straight_p_l],
[gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_es,gl_map_nw,gl_map_straight_p_l,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_es,gl_map_wn,gl_map_se,gl_map_stop,gl_map_cross,gl_map_se,gl_map_stop,gl_map_es,gl_map_straight_v],
[gl_map_wn,gl_map_es,gl_map_wn,gl_map_es,gl_map_nw,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_cross,gl_map_cross,gl_map_straight_h,gl_map_cross,gl_map_se,gl_map_straight_v],
[gl_map_stop,gl_map_straight_p_l,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_t_jiro_n,gl_map_es,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_cross,gl_map_cross,gl_map_cross,gl_map_t_jiro_n,gl_map_cross,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_p_r,gl_map_se,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_nw,gl_map_t_jiro_s,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_cross,gl_map_straight_p_l,gl_map_wn,gl_map_straight_p_l,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_wn,gl_map_se,gl_map_straight_v],
[gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_s,gl_map_cross,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_stop,gl_map_es,gl_map_straight_v],
[gl_map_nw,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_se,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_es,gl_map_nw,gl_map_se,gl_map_straight_v],
[gl_map_wn,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_nw,gl_map_t_jiro_n,gl_map_cross,gl_map_t_jiro_s,gl_map_es,gl_map_stop,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_straight_p_l],
[gl_map_nw,gl_map_se,gl_map_wn,gl_map_se,gl_map_nw,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_p_r,gl_map_se,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v],
[gl_map_straight_v,gl_map_stop,gl_map_straight_h,gl_map_straight_h,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_straight_p_r,gl_map_es,gl_map_nw,gl_map_straight_h,gl_map_t_jiro_s,gl_map_cross,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v],
[gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_stop,gl_map_se,gl_map_nw,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_straight_p_r,gl_map_es,gl_map_stop,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v],
[gl_map_wn,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_squear,gl_map_wn,gl_map_straight_p_l,gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_stop,gl_map_es,gl_map_nw,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_cross,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_nw,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_nw,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_nw,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_cross,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_cross,gl_map_t_jiro_n,gl_map_se],
[gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_wn,gl_map_se,gl_map_wn,gl_map_t_jiro_s,gl_map_straight_h,gl_map_straight_h,gl_map_cross,gl_map_es,gl_map_squear,gl_map_cross,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_s,gl_map_se,gl_map_straight_v,gl_map_none],
[gl_map_none,gl_map_stop,gl_map_se,gl_map_none,gl_map_none,gl_map_none,gl_map_none,gl_map_none,gl_map_stop,gl_map_se,gl_map_stop,gl_map_se,gl_map_stop,gl_map_se,gl_map_stop,gl_map_none,gl_map_none,gl_map_none,gl_map_stop,gl_map_none],
];
//4階層目
var gl_map_data5 = [
[gl_map_squear,gl_map_t_jiro_n,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_n,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_straight_h,gl_map_stop],
[gl_map_straight_v,gl_map_straight_v,gl_map_nw,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_p_r,gl_map_se,gl_map_stop,gl_map_cross,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_nw,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_es,gl_map_straight_p_r,gl_map_straight_h,gl_map_cross,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_cross,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v],
[gl_map_straight_p_r,gl_map_es,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_n,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_t_jiro_s,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_es,gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_nw,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_nw,gl_map_es,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_straight_p_l,gl_map_nw,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_n,gl_map_cross,gl_map_t_jiro_s,gl_map_es,gl_map_straight_v],
[gl_map_wn,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_nw,gl_map_se,gl_map_straight_v],
[gl_map_stop,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_es,gl_map_nw,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_es,gl_map_straight_v],
[gl_map_straight_v,gl_map_nw,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_wn,gl_map_es,gl_map_nw,gl_map_se,gl_map_straight_p_r,gl_map_es,gl_map_nw,gl_map_se,gl_map_straight_v],
[gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_straight_v,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_nw,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_s,gl_map_se,gl_map_nw,gl_map_straight_p_l,gl_map_stop,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_wn,gl_map_se,gl_map_wn,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_se,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_straight_v],
[gl_map_stop,gl_map_t_jiro_n,gl_map_es,gl_map_nw,gl_map_straight_h,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_cross,gl_map_es,gl_map_nw,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_straight_v],
[gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_straight_p_l,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_stop,gl_map_cross,gl_map_straight_h,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v,gl_map_straight_v],
[gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_cross,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_v],
[gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_stop,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_nw,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_es,gl_map_nw,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_cross,gl_map_es,gl_map_stop,gl_map_cross,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_p_l,gl_map_nw,gl_map_es,gl_map_straight_v,gl_map_nw,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v],
[gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_se,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_se,gl_map_squear,gl_map_se,gl_map_wn,gl_map_t_jiro_s,gl_map_se],
];
//5階層目
var gl_map_data6 = [
[gl_map_stop,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_n,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_n,gl_map_es,gl_map_nw,gl_map_es],
[gl_map_straight_p_r,gl_map_straight_h,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_straight_p_r,gl_map_straight_h,gl_map_es,gl_map_nw,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v],
[gl_map_straight_v,gl_map_nw,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_straight_h,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_straight_p_r,gl_map_es,gl_map_wn,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_wn,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_straight_p_l],
[gl_map_wn,gl_map_straight_h,gl_map_se,gl_map_nw,gl_map_se,gl_map_wn,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_nw,gl_map_cross,gl_map_straight_h,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_straight_p_l],
[gl_map_stop,gl_map_t_jiro_n,gl_map_es,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_stop,gl_map_straight_p_l,gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_straight_p_r,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_cross,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_stop,gl_map_es,gl_map_straight_v,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_v],
[gl_map_straight_v,gl_map_nw,gl_map_straight_h,gl_map_cross,gl_map_t_jiro_n,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_wn,gl_map_se,gl_map_nw,gl_map_straight_p_l,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_es,gl_map_wn,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_squear,gl_map_t_jiro_n,gl_map_se,gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_cross,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_nw,gl_map_se,gl_map_nw,gl_map_straight_h,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_se,gl_map_wn,gl_map_se,gl_map_stop,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_straight_p_l,gl_map_nw,gl_map_cross,gl_map_straight_h,gl_map_t_jiro_s,gl_map_straight_p_l,gl_map_stop,gl_map_t_jiro_n,gl_map_es,gl_map_straight_p_r,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_p_l],
[gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_cross,gl_map_se,gl_map_straight_p_r,gl_map_es,gl_map_stop,gl_map_se,gl_map_wn,gl_map_es,gl_map_wn,gl_map_es,gl_map_stop,gl_map_straight_p_l],
[gl_map_stop,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_stop,gl_map_es,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_nw,gl_map_se,gl_map_straight_v,gl_map_straight_v],
[gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_se,gl_map_stop,gl_map_straight_h,gl_map_straight_p_l,gl_map_stop,gl_map_straight_h,gl_map_t_jiro_n,gl_map_se,gl_map_nw,gl_map_t_jiro_s,gl_map_es,gl_map_wn,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_t_jiro_n,gl_map_es,gl_map_nw,gl_map_es,gl_map_stop,gl_map_cross,gl_map_straight_h,gl_map_se,gl_map_wn,gl_map_es,gl_map_straight_v,gl_map_stop,gl_map_se,gl_map_nw,gl_map_se,gl_map_stop,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_nw,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_se,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_es,gl_map_wn,gl_map_se,gl_map_wn,gl_map_es,gl_map_wn,gl_map_straight_h,gl_map_cross,gl_map_straight_p_l],
[gl_map_straight_p_r,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_se,gl_map_wn,gl_map_es,gl_map_stop,gl_map_t_jiro_n,gl_map_se,gl_map_squear,gl_map_straight_h,gl_map_straight_p_l,gl_map_straight_v],
[gl_map_straight_p_r,gl_map_t_jiro_n,gl_map_es,gl_map_squear,gl_map_straight_p_l,gl_map_straight_v,gl_map_stop,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_t_jiro_n,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_wn,gl_map_t_jiro_s,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_straight_h,gl_map_cross,gl_map_straight_p_l],
[gl_map_straight_v,gl_map_wn,gl_map_se,gl_map_straight_v,gl_map_straight_p_r,gl_map_cross,gl_map_straight_p_l,gl_map_straight_v,gl_map_straight_v,gl_map_wn,gl_map_straight_h,gl_map_es,gl_map_stop,gl_map_straight_h,gl_map_es,gl_map_straight_v,gl_map_nw,gl_map_t_jiro_n,gl_map_t_jiro_s,gl_map_straight_p_l],
[gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_se,gl_map_stop,gl_map_se,gl_map_stop,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_straight_h,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_stop,gl_map_t_jiro_s,gl_map_t_jiro_s,gl_map_se,gl_map_wn,gl_map_straight_h,gl_map_se],
];
var gl_map_array_data = [];
var gl_map_array_data_org = [];
//MapIndex
var gl_map_array_index = 0;
var gl_map_index_mori = gl_map_array_index++;
var gl_map_index_mori2 = gl_map_array_index++;
var gl_map_index_mori3 = gl_map_array_index++;
var gl_map_index = 0;
//MapDataIndes
var gl_map_data_index = 0;
var gl_map_data_org_index = gl_map_data_index++;
var gl_map_data_now_index = gl_map_data_index++;
var gl_map_data_exit_index = gl_map_data_index++;
var gl_map_data_next_index = gl_map_data_index++;
//スタート位置
var gl_start_pos_x = 0;
var gl_start_pos_y = 0;
//チェックポイント
var gl_check_point = function(x_pos,y_pos,img_data=null,set_adv_pos=null,treasure=null){
	this.x_pos = x_pos;
	this.y_pos = y_pos;
	this.img_data = img_data;
	this.lc_adv_pos = set_adv_pos;
	this.treasure = treasure;
};

//ダンジョン出口ポイント
var gl_exit_points = [];
//次のエリアポイント
var gl_next_points = [];
var gl_before_points = [];
//宝ポイント
var gl_Treasure_points = [];
//現在地
var gl_now_pos_x = 0;
var gl_now_pos_y = 0;
var gl_save_pos_x = 0;
var gl_save_pos_y = 0;
//現在の方向
var gl_now_adv_pos = 0;
var gl_map_change = false;
//現在の時間帯
var gl_now_time = 0;
//MAPデータ
var gl_noon_data = null;
var gl_evening_data = null;
var gl_nigth_data = null;
var gl_map_drow_image = new Image();
//マップ画像データ
var gl_map_image = [
	[//昼
		['map_straight_v'],
		['map_straight_h'],
		['map_cross'],
		['map_straight_p_r'],
		['map_straight_p_l'],
		['map_nw'],
		['map_wn'],
		['map_se'],
		['map_es'],
		['map_t_jiro_n'],
		['map_t_jiro_s'],
		['map_stop'],
		['map_squear'],
		['map_none'],
	],
	[//夕方
		['map_straight_v'],
		['map_straight_h'],
		['map_cross'],
		['map_straight_p_r'],
		['map_straight_p_l'],
		['map_nw'],
		['map_wn'],
		['map_se'],
		['map_es'],
		['map_t_jiro_n'],
		['map_t_jiro_s'],
		['map_stop'],
		['map_squear'],
		['map_none'],
	],
	[//夜
		['map_straight_v'],
		['map_straight_h'],
		['map_cross'],
		['map_straight_p_r'],
		['map_straight_p_l'],
		['map_nw'],
		['map_wn'],
		['map_se'],
		['map_es'],
		['map_t_jiro_n'],
		['map_t_jiro_s'],
		['map_stop'],
		['map_squear'],
		['map_none'],
	],
];
//マップパーツイメージ
if(typeof gl_map_part_image_path == undefined){
	var gl_map_part_image_path = [
		"./MapChip/map_0.png",
		"./MapChip/map_1.png",
		"./MapChip/map_2.png",
		"./MapChip/map_3.png",
		"./MapChip/map_4.png",
		"./MapChip/map_5.png",
		"./MapChip/map_6.png",
		"./MapChip/map_7.png",
		"./MapChip/map_8.png",
		"./MapChip/map_9.png",
		"./MapChip/map_a.png",
		"./MapChip/map_b.png",
		"./MapChip/map_c.png",
		"./MapChip/map_d.png",
		"./MapChip/map_b1.png",
	];
}
var gl_map_part_image = [];
var ctx;
var ctx2;
var ctxback;
var canvas1;
var canvas2;
var canvas3;
var parentElm = "body";//親要素（要素追加用）
//-----------------------------------------
//マップ-処理
//-----------------------------------------
function MapDataSaveLoad(save_flg=false){
	/*//記録取得
	if(!save_flg){
		var data = storage_func.ReadData("Test_MapData");
		if((data==null)||(data=="null")){
			var saveParam = JSON.stringify(gl_map_array_data);
			storage_func.WriteData("Test_MapData",saveParam);
			gl_map_array_data = JSON.parse(saveParam);
		}else{
			gl_map_array_data = JSON.parse(data);
		}
	}else{
		for(index in gl_map_array_data_org){
			if(gl_map_array_data.length==index){
				gl_map_array_data.push(gl_map_array_data_org[index].concat());
			}
		}
		var saveParam = JSON.stringify(gl_map_array_data);
		storage_func.WriteData("Test_MapData",saveParam);
		gl_map_array_data = JSON.parse(saveParam);		
	}
	MapPosDataSaveLoad(save_flg)}*/
}
function MapPosDataSaveLoad(save_flg=false){
	//記録取得
	/*if(!save_flg){
		var data = storage_func.ReadData("Test_MapPos");
		if((data==null)||(data=="null")){
			var saveParam = JSON.stringify([gl_now_pos_x,gl_now_pos_y,gl_map_index_mori,gl_adv_n]);
			storage_func.WriteData("Test_MapPos",saveParam);
			var buff = JSON.parse(saveParam);
			gl_now_pos_x = buff[0]
			gl_now_pos_y = buff[1];
			gl_map_index = buff[2];
			gl_now_adv_pos = buff[3];
		}else{
			var buff = JSON.parse(data);
			gl_now_pos_x = buff[0]
			gl_now_pos_y = buff[1];
			if(buff.length>=3){
				gl_map_index = buff[2];
			}
			if(buff.length>=4){
				gl_now_adv_pos = buff[3];
			}			
		}
	}else{
		var saveParam = JSON.stringify([gl_now_pos_x,gl_now_pos_y,gl_map_index,gl_now_adv_pos]);
		storage_func.WriteData("Test_MapPos",saveParam);
		var buff = JSON.parse(saveParam);
		gl_now_pos_x = buff[0]
		gl_now_pos_y = buff[1];	
		gl_map_index = buff[2];
		gl_now_adv_pos = buff[3];
	}*/
}
function MapParseXML(e){
	'use strict';
	var xml = e.target.result;
	// XMLのDOMをパースする
	var parser = new DOMParser();
	var dom = parser.parseFromString(xml, 'application/xml');
	gl_noon_data = dom.getElementsByTagName('NOON');
	dom = parser.parseFromString(xml, 'application/xml');
	gl_evening_data = dom.getElementsByTagName('EVENING');
	dom = parser.parseFromString(xml, 'application/xml');
	gl_nigth_data = dom.getElementsByTagName('NIGTH');
}
//Canvas生成
function MakeCanvas(addElement="body"){
	canvas1 = glObj.createElement("canvas","canvas1");
	canvas2 = glObj.createElement("canvas","canvas2");
	canvas3 = glObj.createElement("canvas","canvas3");
	
	for(var loop=0;loop<3;loop++){
		var canvas;
		//縦横設定(1:横,0:縦)	
		var vh_set = 0;
		if(vh_set){
			height = 300;
			width = 400;
		}else{
			//デフォルト値
			height = 550;
			width = 300;
		}
		var widthMax = 400;		
		switch(loop){
		case 0:
			canvas = canvas1;
			height = 112;
			width = 112;
			widthMax = 112;
			break;
		case 1:
			canvas = canvas2;
			height = 112;
			width = 112;
			widthMax = 112;			
			break;
		case 2:
			canvas = canvas3;
			break;
		}
		if(window.innerHeight<=height){
			canvas.height = window.innerHeight;
		}else{
			canvas.height = height;
		}
		if(window.innerWidth>=widthMax){
			canvas.width = widthMax;		
		}else{
			//canvas.width = window.screen.width;
			canvas.width = window.innerWidth;
		}
		canvas.globalAlpha = 1;
		canvas.globalCompositeOperation = "source-in";
		canvas.style.position = "absolute";
	}
	
	
	glObj.addElement(glObj.getElement(addElement),canvas3);
	//glObj.addElement(glObj.getElement(addElement),canvas2);
	//glObj.addElement(glObj.getElement(addElement),canvas1);
	
	ctx = canvas1.getContext('2d');
	ctx2 = canvas2.getContext('2d');
	ctxback = canvas3.getContext('2d');
}
//操作パネル生成
function OperationPanel(addElement="body"){
	//操作パネル本体
	var danjon = glObj.createElement("div","Danjon");
	
	danjon.style = "text-align:center;position:absolute;top:200px;left:288px;width:112px;border:1px solid #000000;opacity:0.8;background-color:#303030;color:#FFFFFF;";
	//進行方向
	var adx = glObj.createElement("span","adx","",function(elm){
		elm.innerText = "方向:北";
	});
	//進行方向：上
	var n = glObj.createElement("button","n","",function(elm){
		elm.innerText = "↑";
	});
	//進行方向：左
	var e = glObj.createElement("button","e","",function(elm){
		elm.innerText = "←";
	});
	//進行方向：右
	var w = glObj.createElement("button","w","",function(elm){
		elm.innerText = "→";
	});
	//進行方向：下
	var s = glObj.createElement("button","s","",function(elm){
		elm.innerText = "↓";
	});
	//座標：X
	var pos_x = glObj.createElement("span","pos_x","",function(elm){
		elm.innerText = "X:0";
	});
	//座標：空白
	var escape_p = glObj.createElement("span","escape_p","",function(elm){
		elm.innerHTML = "&nbsp;";
	});
	//座標：Y
	var pos_y = glObj.createElement("span","pos_y","",function(elm){
		elm.innerText = "Y:0";
	});
	//パネル本体追加
	glObj.addElement(glObj.getElement(addElement),danjon);
	//進行方向表示追加
	glObj.addElement(danjon,adx);
	//改行
	glObj.addElement(danjon,glObj.createElement("br",""));
	//進行方向上ボタン追加
	glObj.addElement(danjon,n);
	//改行
	glObj.addElement(danjon,glObj.createElement("br",""));
	//進行方向左ボタン追加
	glObj.addElement(danjon,e);
	//進行方向右ボタン追加
	glObj.addElement(danjon,w);
	//改行
	glObj.addElement(danjon,glObj.createElement("br",""));
	//進行方向下ボタン追加
	glObj.addElement(danjon,s);
	//改行
	glObj.addElement(danjon,glObj.createElement("br",""));
	//座標追加
	glObj.addElement(danjon,canvas1);
	glObj.addElement(danjon,canvas2);
	glObj.addElement(danjon,pos_x);
	glObj.addElement(danjon,escape_p);
	glObj.addElement(danjon,pos_y);
	canvas1.style="position:absolute;top:-112px;left:0px;display:none;"
	canvas2.style="position:absolute;top:-112px;left:0px;"
	
}
function MapInitialize(map_time=0){
	//マップ初期化
	gl_map_data = gl_map_data2;
	//Canvas生成
	MakeCanvas(parentElm);
	//操作パネル生成
	OperationPanel(parentElm);
	//マップ変更フラグ
	gl_map_change = false;
	//マップインデックス
	gl_map_index = gl_map_index_mori;
	//マップデータ配列
	gl_map_array_data_org = [
		[gl_map_data2,gl_map_data.concat()],
		[gl_map_data3,gl_map_data.concat()],
		[gl_map_data4,gl_map_data.concat()],
		[gl_map_data5,gl_map_data.concat()],
		[gl_map_data6,gl_map_data.concat()]
	];
	gl_map_array_data = gl_map_array_data_org.concat();
	//現在地
	gl_now_pos_x = gl_start_pos_x;
	gl_now_pos_y = gl_start_pos_y;
	//進行方向
	gl_now_adv_pos = gl_adv_n;

	//Exitポイント
	gl_exit_points.push(new gl_check_point(0,0,1,gl_adv_n));
	//次エリア
	gl_next_points.push(new gl_check_point(6,18,1,gl_adv_n));
	gl_next_points.push(new gl_check_point(0,18,1,gl_adv_e));
	gl_next_points.push(new gl_check_point(12,14,1,gl_adv_n));
	gl_next_points.push(new gl_check_point(14,5,1,gl_adv_e));
	//前エリア
	gl_before_points.push(new gl_check_point(-1,-1,1,gl_adv_n));
	gl_before_points.push(new gl_check_point(18,19,1,gl_adv_e));
	gl_before_points.push(new gl_check_point(1,19,1,gl_adv_e));
	gl_before_points.push(new gl_check_point(10,2,1,gl_adv_n));
	gl_before_points.push(new gl_check_point(14,5,1,gl_adv_n));
	
	//時間設定(デフォルト昼)
	SetNowTime(map_time);
	//XML読み込み
    // Fileオブジェクトデータ生成
	var str = xmlData;
	var source = [ str ];	
	var file_property_bag = {
		// コンテンツタイプを設定
		type: "text/plain",
		// 最終更新日時を設定（単位：ミリ秒）
		lastModified: 0
	};
    var file = new File( source , "./map_data/imageData.xml" , file_property_bag );
    var reader = new FileReader();
    reader.addEventListener('load', MapParseXML, false);
    reader.readAsText(file);
	MapPartImageLoad();
	SetDestination();
}

//マップパーツ読み込み
var local_lock = false;
function MapPartImageLoad(){
	//ループ
	if(gl_map_part_image.length!=gl_map_part_image_path.length){
		var load_image = new Image();
		if(!local_lock){
			local_lock = true;
			load_image.src = gl_map_part_image_path[gl_map_part_image.length];
			load_image.onload = function(){
				gl_map_part_image.push(load_image);
				local_lock = false;
				setTimeout(MapPartImageLoad,100);
				if(gl_map_part_image.length==gl_map_part_image_path.length){
					console.log(JSON.stringify(gl_map_part_image));
				}
			}
		}
	}
}
//時間帯セット(昼、夕方、夜)
function SetNowTime(timeIndex){
	gl_now_time = timeIndex;
	if(gl_now_time>=gl_map_image.length){
		gl_now_time = 2
	}
}
//マップデータ位置取得
function GetMapDataIndex(set_x = gl_now_pos_x,set_y=gl_now_pos_y){
	var res = gl_map_array_data[gl_map_index][gl_map_data_org_index];
	return res[set_y][set_x];
}
//画像データ取得
function GetMapImage(){
	var map_data_index = GetMapDataIndex();
	var res = null;
	var buff;
	buff = gl_map_image[gl_now_time][map_data_index];
	if(gl_now_time==0){
		var nodes = gl_noon_data[0].childNodes;
		for(var ndLoop=0;ndLoop<nodes.length;ndLoop++){
			if(nodes[ndLoop].nodeName=="IMGDATA"){
				if(nodes[ndLoop].attributes[0].value==buff){
					var adx = nodes[ndLoop].attributes[1].value;
					if((adx==-1)||(adx==gl_now_adv_pos)||gl_map_change){
						res = nodes[ndLoop].textContent;
						break;
					}
				}
			}
		}
	}
	if(gl_now_time==1){
		var nodes = gl_evening_data[0].childNodes;
		for(var ndLoop=0;ndLoop<nodes.length;ndLoop++){
			if(nodes[ndLoop].nodeName=="IMGDATA"){
				if(nodes[ndLoop].attributes[0].value==buff){
					var adx = nodes[ndLoop].attributes[1].value;
					if((adx==-1)||(adx==gl_now_adv_pos)||gl_map_change){
						res = nodes[ndLoop].textContent;
						break;
					}
				}
			}
		}		
	}
	if(gl_now_time==2){
		var nodes = gl_nigth_data[0].childNodes;
		for(var ndLoop=0;ndLoop<nodes.length;ndLoop++){
			if(nodes[ndLoop].nodeName=="IMGDATA"){
				if(nodes[ndLoop].attributes[0].value==buff){
					var adx = nodes[ndLoop].attributes[1].value;
					if((adx==-1)||(adx==gl_now_adv_pos)||gl_map_change){
						res = nodes[ndLoop].textContent;
						break;
					}
				}
			}
		}		
	}
	return res;
}
//移動可能方向
function GetMovePassMap(){
	var res = false;
	var map_idx = GetMapDataIndex();
	var part_idx = gl_map_part[map_idx][gl_now_adv_pos];
	return part_idx;
}
//移動可能方向パーツデータ取得
function GetMovePassPart(){
	var idx = GetMovePassMap();
	return gl_pass_data[idx];
}
//移動
function MoveMap(select_adv){
	var part_idx = GetMovePassMap();
	var pass_flg = 0;
	var res = false;
	//進行方向移動チェック
	pass_flg = gl_pass_data[part_idx][select_adv];
	if(pass_flg){
		switch(select_adv){
			case gl_adv_n:
				gl_now_pos_y--;
				break;
			case gl_adv_s:
				gl_now_pos_y++;
				break;
			case gl_adv_e:
				gl_now_pos_x--;
				break;
			case gl_adv_w:
				gl_now_pos_x++;
				break;
		}
		//値調整
		var lc_map_data2 = gl_map_array_data[gl_map_index][gl_map_data_org_index];
		if(gl_now_pos_y>=lc_map_data2.length){
			gl_now_pos_y--;
		}
		if(gl_now_pos_x>=lc_map_data2[0].length){
			gl_now_pos_x--;
		}
		//方向設定
		gl_now_adv_pos = select_adv;
		res = true;
	}
	return res;
}
function SetDestination(){
	document.getElementById("n").onclick = function(){
		MoveMap(gl_adv_n);
		pos_change();
	}
	document.getElementById("s").onclick = function(){
		MoveMap(gl_adv_s);
		pos_change();
	}
	document.getElementById("e").onclick = function(){
		MoveMap(gl_adv_e);
		pos_change();
	}
	document.getElementById("w").onclick = function(){
		MoveMap(gl_adv_w);
		pos_change();
	}
}
//木材集め処理
function Item1Event(){
	var msg = "";
	var now_pos_data = GetMapDataIndex();
	if(gl_map_stop==now_pos_data){
		var event_data = GetEventData("木材集め");
		if(event_data[id_ev_proc_flg]){
			var random = Math.floor(Math.random()*10);
			if(random==3){
				msg = "木材を見つけました。";
				var res = Requstting("itme1");
				if(res){
					msg = msg + "<br>依頼数集まりましたので戻りましょう。";
				}
			}else{
				msg = "木材はありませんでした。<br>他のところを探してみましょう。";
			}
		}
	}
	return msg;
}
//木材集め処理
function Item2Event(){
	var msg = "";
	var now_pos_data = GetMapDataIndex();
	if(gl_map_stop==now_pos_data){
		var event_data = GetEventData("キノコ狩り");
		if(event_data[id_ev_proc_flg]){
			var random = Math.floor(Math.random()*10);
			if(random==4){
				var msg = "";
				msg = "キノコを見つけました。";
				var res = Requstting("itme2");
				if(res){
					msg = msg + "<br>依頼数集まりましたので戻りましょう。";
				}
			}else{
				msg = "キノコはありませんでした。<br>他のところを探してみましょう。";
			}
		}
	}
	return msg;
}
//森の主イベント
function BossEvent(){
	var msg = "";
	var now_pos_data = GetMapDataIndex();
	if(gl_map_stop==now_pos_data){
		//第一エリア限定
		if(gl_map_index==gl_map_index_mori){
			msg = BossEvent1(msg);
		}
		//第二エリア限定
		if(gl_map_index==gl_map_index_mori2){
			msg = BossEvent2(msg);
		}
	}
	return msg;
}
//森の主イベント(第1エリア)
function BossEvent1(msg){
	var event_data = GetEventData("魔物討伐１");
	if(event_data[id_ev_proc_flg]){
		var random = Math.floor(Math.random()*30)+1;
		if(random%3==0){
			var msg = "";
			msg = personal_name1+"<br>「こ、これが森に住み着いた魔物！？」";
			setTimeout(function(){
				boss_flg = true;
				EventActionCheck();
			},1000);
		}else{
			msg = "魔物はいませんでした。<br>他のところを探してみましょう。";
		}
	}
	return msg;	
}
//森の主イベント(第2エリア)
function BossEvent2(msg){
	var event_data = GetEventData("魔物討伐2");
	if(event_data[id_ev_proc_flg]){
		var random = Math.floor(Math.random()*30)+1;
		if(random%3==0){
			var msg = "";
			msg = personal_name1+"<br>「オ、オーラが前の魔物と違う！？」";
			setTimeout(function(){
				boss_flg = true;
				EventActionCheck();
			},1000);
		}else{
			msg = "魔物はいませんでした。<br>他のところを探してみましょう。";
		}
	}
	return msg;	
}
//出口処理
function DanjonExit(ExitIndex){
	var res = false;
	var img_exit_data = 0;
	if(gl_exit_points.length==0)return res;
	img_exit_data = gl_exit_points[ExitIndex].img_data;
	if(image_back_index != img_exit_data){
		var x_pos = gl_exit_points[ExitIndex].x_pos;
		var y_pos = gl_exit_points[ExitIndex].y_pos;
		//座標チェック
		if((gl_now_pos_x==x_pos)&&(gl_now_pos_y==y_pos)){
			image_back_index = img_exit_data;
			res = true;
		}else{
			image_back_index = id_back_mori;
		}
		ev_enemy_flg = true;
	}else{
		image_back_index = id_back_mori;
		ev_before_select_reset = false;
		ev_enemy_flg = false;		
	}
	return res;
}

//進行方向設定
function SetAdvData(adv_data){
	if(adv_data[gl_adv_n]){
		document.getElementById("n").disabled="";
	}else{
		document.getElementById("n").disabled="disabled";
	}
	if(adv_data[gl_adv_s]){
		document.getElementById("s").disabled="";
	}else{
		document.getElementById("s").disabled="disabled";
	}
	if(adv_data[gl_adv_e]){
		document.getElementById("e").disabled="";
	}else{
		document.getElementById("e").disabled="disabled";
	}
	if(adv_data[gl_adv_w]){
		document.getElementById("w").disabled="";
	}else{
		document.getElementById("w").disabled="disabled";
	}	
}
var xPos_view = 0;//220
var yPos_view = 0;//180
var startFlg = false;
function pos_change(){
	ctx.clearRect(0,0,112,112);
	document.getElementById("pos_x").innerText="x:"+gl_now_pos_x;
	document.getElementById("pos_y").innerText="y:"+gl_now_pos_y;
	var adx_text = document.getElementById("adx");
	var adv_data = GetMovePassPart();
	var background_img = document.getElementById("image_data");
	//進行方向設定
	SetAdvData(adv_data);
	switch(gl_now_adv_pos){
		case gl_adv_n:
			adx_text.innerText = "方向：北";
			break;
		case gl_adv_s:
			adx_text.innerText = "方向：南";
			break;
		case gl_adv_e:
			adx_text.innerText = "方向：東";
			break;
		case gl_adv_w:
			adx_text.innerText = "方向：西";
			break;
	}
	//map_text.innerHTML = buff;
	//if(Initialize_img_flg)return;
	var imgData = GetMapImage();
	var lc_map_data = gl_map_array_data[gl_map_index][gl_map_data_org_index];
	//var lc_map_data = gl_map_array_data[gl_map_index][gl_map_data_now_index];
	//var lc_map_data2 = gl_map_array_data[gl_map_index][gl_map_data_org_index];
	gl_map_drow_image.src=imgData;
	//image_pos_index = parseInt(image_back_index/4);
	gl_map_drow_image.onload = function(){
		//2次元画像指定&画像サイズ指定
		var gl_now_pos_x_back = 0;
		var gl_now_pos_y_back = 0;
		var x_start = 0;
		var y_start = 0;
		var x_limit = 6;
		var y_limit = 6;
		if(gl_now_pos_x>x_limit){
			x_start = gl_now_pos_x-x_limit;
		}
		if(gl_now_pos_y>y_limit){
			y_start = gl_now_pos_y-y_limit;
		}
		var res = ctxback.drawImage(gl_map_drow_image, -210, 0,800,600);
		for(var y_idx = y_start;(y_idx<lc_map_data.length)&&(y_idx<(y_start+y_limit+1));y_idx++){
			for(var x_idx = x_start;(x_idx<lc_map_data[y_idx].length)&&(x_idx<(x_start+x_limit+1));x_idx++){
				/*//マップ更新用
				if((y_idx == gl_now_pos_y)&&((x_idx-x_start) == gl_now_pos_x)){
					lc_map_data[y_idx][x_idx] = lc_map_data2[y_idx][x_idx];
				}*/
				//マップデータインデックス取得
				if(gl_now_pos_x>=x_limit){
					gl_now_pos_x_back = gl_now_pos_x;
					gl_now_pos_x = x_limit;
				}
				if(gl_now_pos_y>=y_limit){
					gl_now_pos_y_back = gl_now_pos_y;
					gl_now_pos_y = y_limit;
				}
				var setStr = lc_map_data[y_idx][x_idx];
				var treasureFlg = myRpg.Charctor.TREASURE?myMap.ChecnkTreasure(true,[x_idx,y_idx]):false;
				if(!treasureFlg){
					var res = ctx.drawImage(gl_map_part_image[setStr],xPos_view+(16*(x_idx-x_start)),yPos_view+(16*(y_idx-y_start)),16,16);
				}else{
					setStr = gl_map_part_image.length-1;
					var res = ctx.drawImage(gl_map_part_image[setStr],xPos_view+(16*(x_idx-x_start)),yPos_view+(16*(y_idx-y_start)),16,16);
				}
				//現在地用
				if(((y_idx-y_start) == gl_now_pos_y)&&((x_idx-x_start) == gl_now_pos_x)){
					ctx.fillStyle="red";     //塗りつぶしの色を赤に指定
					ctx.fillRect(xPos_view+(16*(x_idx-x_start))+4,yPos_view+(16*(y_idx-y_start))+4,8,8);
				}
				if(gl_now_pos_x_back!=0)gl_now_pos_x = gl_now_pos_x_back;
				if(gl_now_pos_y_back!=0)gl_now_pos_y = gl_now_pos_y_back;
			}
		}
		//ctx2.clearRect(0,0,112,112);
		if(!startFlg){
			ctx2.drawImage(canvas1,0,0);
		}else{
			setTimeout(function(){
				ctx2.drawImage(canvas1,0,0);
			},100);
		}

		//エリア変更チェック
		myMap.ChangeAreaCheck();

        //宝箱表示
        myMap.ChecnkTreasure();
		
		//エロトラップ表示
		myMap.EroEventFunc();
        
		//階段表示
		if(myMap.MapExit()){//出口
			myMap.image.src = myMap.ViewMapItem(myMap.UpStep,true);
			myMap.image.onload = function(){
				ctxback.drawImage(myMap.image, -130,100,800*0.8,600*0.8);
			}
		}
		if(myBT.NextAreaFlg){//次の階
			myMap.image.src = myMap.ViewMapItem(myMap.DownStep,true);
			myMap.image.onload = function(){
				ctxback.drawImage(myMap.image, -130,100,800*0.8,600*0.8);
			}
		}
		if(myBT.BeforeAreaFlg){//前の階
			myMap.image.src = myMap.ViewMapItem(myMap.UpStep,true);
			myMap.image.onload = function(){
				ctxback.drawImage(myMap.image, -130,100,800*0.8,600*0.8);
			}
		}
		//安全地帯
		if(myMap.SafeSpaceFunc()){
			myMap.image.src = myMap.ViewMapItem(myMap.SafeSpace,true);
			myMap.image.onload = function(){
				ctxback.drawImage(myMap.image, -130,100,800*0.8,600*0.8);
			}
		}
	}
	
	//戦闘判定
	myMap.Battle();
}