/// @description 

if (global.game_state != GAME_STATE.GAME) {
	alarm[0]++;
	alarm[1]++;
	exit;
}

if (alarm[0] == -1) {
	var _xx = x div BLOCK_WIDTH;
	var _yy = y div BLOCK_HEIGHT;
	var _b = tilemap_get(global.road_tile, _xx, _yy);
	var _walk = false;
	if (sc_tile_is_road(_b)) {
		dir = (_b-ROAD_TYPE.RR)*90;
		_walk = true;
	}
	else if (_b == ROAD_TYPE.ROAD) {
		var _rand = -1;
		var _rand_dir = dir;
		while(!sc_tile_is_road(_rand)) {
			_rand_dir = dir + (choose(-1, 0, 1) * 90);
			_rand = tilemap_get(global.road_tile,
				_xx+lengthdir_x(1, _rand_dir), _yy+lengthdir_y(1, _rand_dir));
			_walk = true;
		}
		_b = _rand;
		dir = _rand_dir;
	}
	if (_walk && sc_tile_is_road(_b)) {
		x += lengthdir_x(BLOCK_WIDTH, dir);
		y += lengthdir_y(BLOCK_HEIGHT, dir);
		
		image_speed = 1-(min(spd_delay/10/image_number, 0.9));
	}
	if (xprevious != x)
		image_xscale = sign(x-xprevious);
	alarm[0] = spd_delay;
}

x_draw = lerp(x_draw, x, 0.2);
y_draw = lerp(y_draw, y, 0.2);