function main()
{
fps_max = 75;
level_load("1.WMB");
wait(3);
}
function got_scanned()
{
my.event = NULL; // the entities will follow the magnet from now on
VECTOR temp_pos;
wait(1);
while (1)
{
if (vec_dist (player.x, my.x) > 50) // the object isn't close enough to the magnet?
{
vec_set(temp_pos, player.x);
vec_sub(temp_pos, my.x);
vec_to_angle(my.pan, temp_pos);
my.tilt = 0;
// the entity is oriented towards the magnet here
c_move (my, vector(3 * time_step, 0, 0), nullvector, GLIDE);
}
wait (1);
}
}
// the entities that have this action attached to them are sensitive to the magnet entity
action sensitive_ents()
{
my.emask |= ENABLE_SCAN; // make this entity sensitive to scanning
my.event = got_scanned;
}
action my_magnet() // attach this action to your entity
{
player = my; // I'm the player
while (1)
{
// move the player using the cursor keys
c_move (my, vector(10 * (key_cuu - key_cud) * time_step, 6 * (key_cul - key_cur) * time_step, 0), nullvector, GLIDE);
vec_set (camera.x, player.x); // use player's x and y for the camera as well
camera.z += 500; // place the camera 500 quants above the player on the z axis
camera.tilt = -90;
// make the magnet active on a radius of up to 200 quants around it
c_scan(my.x, my.pan, vector(360, 180, 200), IGNORE_ME);
wait (1);
}
}