set_worm_delay(0.01);
init_worm("........ooooooooooOOOOOOOOOoooooooooo.........oooooooooOOOOOOOOOOOOoooooooo...... ");

my $k = "";
my $x = 1;
my $mode = 1;
my $yhalf = int( $ym / 2 );
my $xmax = $xm; #90;
while($k ne"x"){
    my $kt=ReadKey(-1);if(defined($kt)&&$kt=~/[x]/){$k=$kt}
    if ( $mode == 1 ) { $x++ } else { $x-- }
    if ( $x >= $xmax ) { $mode = 0 }
    if ( $x <=     1 ) { $mode = 1 }

    # sidling
    $yy  = int( sin( $x/8 ) *4);
    if ( $mode == 1 ) {	$yy = $yhalf + $yy +3 } else { $yy = $yhalf - $yy - 3 }
    my $xx = $x;

#    my $yy = $yhalf - cos( $x ) * ( sin( $x ) * xm );
#    my $xx =          sin( $x ) * ( sin( $x ) * xm );

    creep_worm( $xx, $yy ); 
    gotoxy( 3, 3 );
    print $xx,"\n",$yy;
}
