task ObjRender_SetDestAtFrame(obj, x, y, frames){
    let ox = ObjRender_GetX(obj);
    let oy = ObjRender_GetY(obj);
    let xc = (x-ox)/frames;
    let yc = (y-oy)/frames;
    loop(frames){
        ox += xc;
        oy += yc;
        ObjRender_SetX(obj, ox);
        ObjRender_SetY(obj, oy);
        yield;
    }
}

function holdup(n){loop(n){yield;}}
function PolygonPShot(x, y, speed, angle, nSide, bpSide, special, graphic, dmg, pen){
    let bpos_x = [];
    let bpos_y = [];
    ascent(i in 0..nSide){
        let tmp_angle = 360 / nSide * i;
        bpos_x = bpos_x ~ [cos(tmp_angle)];
        bpos_y = bpos_y ~ [sin(tmp_angle)];
    }

	let B = []; let z = 0;
    ascent(i in 0..nSide){
        let from_x = x + bpos_x[i % nSide];
        let from_y = y + bpos_y[i % nSide];
        let to_x = x + bpos_x[(i + special) % nSide];
        let to_y = y + bpos_y[(i + special) % nSide];

        ascent(j in 0..bpSide){
            let tmp = (j + 1) / bpSide;

            let vx = GetLinePosition(from_x, to_x, tmp);
            let vy = GetLinePosition(from_y, to_y, tmp);
            let dx = vx - x;
            let dy = vy - y;
            let va = atan2(dy, dx) + angle;
            let vs = (dx * dx + dy * dy) ^ 0.5;

           //CreateShotA1(x, y, vs * speed, va, graphic, delay);
			B = B ~ [CreatePlayerShotA1(x, y, vs*speed, va, dmg, pen, graphic)];
			Obj_SetValue(B[z], "sv", vs);
			Obj_SetValue(B[z], "av", va);
			z++;
        }
    }
	
	return B;
    function GetLinePosition(from_pos, to_pos, pos_t){
        return (from_pos + (to_pos - from_pos) * pos_t);
    }
}
function GetDist(x1,y1,x2,y2){return ((x2-x1)^2+(y2-y1)^2)^0.5;}
function GetAngle(x1,y1,x2,y2){return atan2(y2-y1,x2-x1);}
function Getx(obj){return ObjMove_GetX(obj);}
function Gety(obj){return ObjMove_GetY(obj);}