float clear[21];
float BLOCK_SIZE = 72;

float o4;
float o5;
float o6a;
float o6b;
float o13;
float o15;

float init() {
	set_start_place(72,76,0,0);
	
	o4 = make("res/object/_HamBurger.bcm");
	move_block(o4, 13.5, 1, 4.5, 0);
	
	o5 = make("res/object/_HamBurger.bcm");
	move_block(o5, 17.5, 1, 4.5, 0);
	
	o6a = make("res/object/_HamBurger.bcm");
	move_block(o6a, 0.5, 1, -3.5, 0);
	o6b = make("res/object/_HamBurger.bcm");
	move_block(o6b, 2.5, 1, -3.5, 0);
	
	o13 = make("res/object/_HamBurger.bcm");
	move_block(o13, -11.5, 1, 2.5, 0);
	
	o15 = make("res/object/_Wall.bcm");
	move_block(o15, -19.5, 1, 4.5, 0);
}

float main() {
	set_clear_state(1, enter_block_anyone(clear[1], 0,0.5,6, 3,2,1));
	set_clear_state(2, enter_block_anyone(clear[2], 6,0.5,6, 1,2,1));
	set_clear_state(3, enter_block_anyone(clear[3], 8,0.5,6, 3,2,1));

	set_clear_state(4, enter_block(o4, clear[4], 12,0.5,6, 3,1,1));
	set_clear_state(5, enter_block(o5, clear[5], 18,0.5,6, 1,1,1));
	
	set_clear_state(6, enter_block(o6a, clear[6], 1.375,0.5,-4.625, 0.25,1,0.25) && enter_block(o6b, clear[6], 1.375,0.5,-4.625, 0.25,1,0.25));
	
	set_clear_state(7, enter_block_anyone(clear[7], 5,0.5,-6, 1,2,1));
	set_clear_state(8, enter_block_anyone(clear[8], 10,0.5,-6, 1,2,1));
	set_clear_state(9, enter_block_anyone(clear[9], 12,0.5,-6, 3,2,1));
	set_clear_state(10, enter_block_anyone(clear[10], 16,0.5,-6, 3,2,1));
	
	set_clear_state(11, enter_block_anyone(clear[11], -5,2.5,6, 3,2,1));
	set_clear_state(12, enter_block_anyone(clear[12], -9,0.5,6, 3,2,1));
	
	set_clear_state(13, enter_block(o13, clear[13], -12,0.5,5, 1,1,1));
	
	set_clear_state(14, enter_block_anyone(clear[14], -17,0.5,6, 3,2,1));
	set_clear_state(15, enter_block_anyone(clear[15], -21,0.5,6, 3,2,1));
}

float action(float id) {
	print_str("アクションは無効です");
	println(id);
}

float move_block(float id, float x, float y, float z, float r) {
	move(id, x*BLOCK_SIZE,y*BLOCK_SIZE,z*BLOCK_SIZE, r);
}
float enter_block_anyone(float before, float x, float y, float z, float w, float h, float d) {
	float any = 0;
	float i = 0;
	while (i < get_player_num()) {
		any = any || enter_block(get_player_id(i), before, x,y,z, w,h,d);
		i = i+1;
	}
	return any;
}
float enter_block(float id, float before, float x, float y, float z, float w, float h, float d) {
	return enter_area(id, before, x*BLOCK_SIZE,y*BLOCK_SIZE,z*BLOCK_SIZE,w*BLOCK_SIZE,h*BLOCK_SIZE,d*BLOCK_SIZE);
}

float enter_area(float id, float before, float x, float y, float z, float w, float h, float d) {
	return in_area(id, x,y,z,w,h,d) || (before && cross_area(id, x,y,z,w,h,d));
}

float set_clear_state(float stage, float state) {
	if (!clear[stage] && state) {
		print_str("#ステージ");
		print_int(stage);
		print_str(" クリア!");
		println(-1);
	}
	clear[stage] = state;
}