Information about object: Projectile
Sprite:
Solid: false
Visible: true
Depth: -1
Persistent: false
Parent: Entity
Children:
Mask:
No Physics Object
Create Event:
execute code:
/// Init Projectile Variables
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Config
//////////////////////////////////////////////////////////////////////////////////////////////////////
config = ds_map_create();
hitbox = ds_map_create();
physics = ds_map_create();
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Variables
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Creation Vars
json = -1;
sprite = -1;
flipped = 0;
tails = 0;
// Flag Vars
active = false;
update = false;
collision = false;
// Hitbox Vars
rectangle[0] = 0; rectangle[1] = 0; rectangle[2] = 15; rectangle[3] = 15;
damage = 0;
hits = 1;
// Physics Vars
angular = 0;
angular_wrap = 1;
angular_peak = 0;
angular_base = 0;
angular_value = 0;
angular_accel = 0;
angular_decel = 0;
angular_homing = 0;
velocity = 0;
velocity_wrap = 0;
velocity_peak = 0;
velocity_base = 0;
velocity_value = 0;
velocity_accel = 0;
velocity_decel = 0;
velocity_homing = 0;
amplitude = 0;
amplitude_wrap = 1;
amplitude_peak = 0;
amplitude_base = 0;
amplitude_value = 0;
amplitude_accel = 0;
amplitude_decel = 0;
amplitude_homing = 0;
oscillation = 0;
oscillation_x = x;
oscillation_y = y;
oscillation_wrap = 1;
oscillation_peak = 0;
oscillation_base = 0;
oscillation_value = 0;
oscillation_accel = 0;
oscillation_decel = 0;
oscillation_homing = 0;
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Builin Variables
//////////////////////////////////////////////////////////////////////////////////////////////////////
sprite_index = -1;
visible = false;
alarm[0] = 1;
Alarm Event for alarm 0:
execute code:
///Call Projectile Active
// Reset position spawner objects position
if (spawner.object_index != Projectile)
{
x = spawner.muzzle_x;
y = spawner.muzzle_y;
}
else
{
x = spawner.xstart;
y = spawner.ystart;
}
// Set Builtin Vars
sprite_index = sprite;
visible = 1;
// Flags
collision = true;
active = true;
Step Event:
execute code:
/// Update Projectile
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Tail
//////////////////////////////////////////////////////////////////////////////////////////////////////
if ((instance_exists(spawner)) && (spawner.object_index != Projectile))
if (tails > 0)
{
scr_projectile_spawn(json, config[? "id"], depth, 90, xstart, ystart)
tails --;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Movement
//////////////////////////////////////////////////////////////////////////////////////////////////////
if (update)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Wave Motion
//////////////////////////////////////////////////////////////////////////////////////////////////////
amplitude_value = clamp((amplitude_value + amplitude_accel) - amplitude_decel, amplitude_base, amplitude_peak);
oscillation_value = clamp((oscillation_value + oscillation_accel) - oscillation_decel, oscillation_base, oscillation_peak);
oscillation += degtorad(oscillation_value);
var _shift = amplitude * sin(oscillation);
oscillation_x += lengthdir_x(velocity, angular+90);
oscillation_y += lengthdir_y(velocity, angular+90);
x = oscillation_x + lengthdir_x(_shift, angular + 180);
y = oscillation_y + lengthdir_y(_shift, angular + 180);
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Linear Motion
//////////////////////////////////////////////////////////////////////////////////////////////////////
//x += lengthdir_x(velocity, angular + 90);
//y += lengthdir_y(velocity, angular + 90);
var test = 0;
}
Draw Event:
execute code:
///Draw Self
draw_self();
if (active == true && update != true) { update = !update; }
for (var _i=0; _i<instance_number(Projectile);_i++)
{
var _inst = instance_find(Projectile, _i);
draw_set_colour(c_red);
draw_set_font(fnt_small);
draw_text(0, 0 + (8 * _i), _inst.alarm[0]);
}