Automated Turret の動作を関数で手軽に実現。

リソースのスプライトは最初から左向き(一八〇度)であること。

GM_Studio_14_sprite_Automated_turret_facing_left_default_sample_screenshot

動作デモ:● Automated Turret

Create イベント用

///Init_Turret();
/*
Sprite of the turret should be created facing Left.
*/
diff = 0;

Step イベント用

///Step_Turret( Value, x, y );
/*
var a,b,c;
a = 2;
b = mouse_x;
c = mouse_y
Step_Turret(a,b,c);
*/
var a = ceil(point_direction(x, y, argument1, argument2));
var b = floor(angle_difference(image_angle, a));
var c = diff;
var d = argument0;
    if (abs((360+b) - c) > d){
         image_angle += min(abs(b), d) * sign(b);
         diff         = abs(b); 
    }
    else 
    {
         image_angle  = a-180;
    };

ライブラリ一覧へ戻る

Leave a Reply

Your email address will not be published. Required fields are marked *