Pursuits

The Pursuit alteration will cause the sprite to follow another sprite. If no speed is given then the pursuing sprite will not move but only point at the sprite that it is following.

create routine as Start launch ball launch arrow end create sprite from arrow1.png as arrow where x=150 and y=170 and center=50,26 and angle=90 and size=0.25 having alt=pursuit1 end create pursuit as pursuit1 where prey=ball and speed=230 and follow=300 end create sprite from ball1.png as ball where x=150 and y=30 and center=25,25 having alt=move1 end create translation as move1 where x=random(0,300) and y=random(0,300) and speed=100 and completion=DoneTrans end create routine as DoneTrans insert into ball where alt=move1 end

Parameters

follow={number}
speed of rotation toward prey in degrees per second
prey={sprite}
the name of the sprite to follow
speed={number}
speed of pursuit in pixels per seconds