Box2D

 view release on metacpan or  search on metacpan

examples/pendulum.pl  view on Meta::CPAN

# last location of end of pendulum
my $prev_path_pos;

$app->add_show_handler(
    sub {
        for (1..$precision){
            $world->Step( $timestep, $vIters, $pIters );
            $world->ClearForces();
        }
        
        my $endpoint = $bobs[$#bobs]{body}->GetPosition();
        my $current_path_pos
            = [ w2s( $endpoint->x ), w2s( s2w($height) - $endpoint->y ) ];

        # trace path on bg
        $bg->draw_line( $prev_path_pos, $current_path_pos, $pathColor )
            if $prev_path_pos;
        $prev_path_pos = $current_path_pos;

        # draw bg
        $bg->blit( $app, [ 0, 0, $width, $height ] );

        # draw 1st pendulum

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.544 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )