function bounce_off() // ball's event function
{
vec_to_angle(my.pan, bounce); // change the direction as expected from a "real" ball
my.pan += 5 - random(10); // add some randomness at each collision (don't allow the ball to get stuck)
}
action my_sprite() // attach this action to your ball
{
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); // the object is sensitive to block and entity collisions
my.event = bounce_off;
while(1)
{
c_move(me, vector(5 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE); // move ahead, in the direction given by the pan angle
wait(1);
}
}