Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Nice!

Let me contribute by pollishing up the look of your script (you deserve this):

(just replace your comments and the

use Tk;
before them with this...)

use Getopt::Long; use Pod::Usage; use Tk; my $VERSION='1.00'; =pod =head1 NAME [ TkRollerCoaster.pl ] =head1 DESCRIPTION There was an "advanced perl programming" weekly contest awhile back( +now defunct I think". One I entered was a roller coaster simulation. The original contest h +ad various *.rc files to make any kind of coaster track design. I just included a nice one +in DATA, to make the script self-contained. This approach is a very simple method to simulate the roller-coaster motion. I didn't waste any time on actually computing the velocities or positions, rather I relied on the Law of Conservation of Energy, which says that the sum of the Kinetic and Potential Energies will remain constant. The initial total energy is the potential energy at the highest point, and that is released into kinetic energy( i.e. velocity) as the coaster drops. So as the coaster drops, it's KE increases, and as the coaster climbs it's KE decreases, and stalls if it climbs past it's start height. I figured this was the best approach, since we don't have an actual equation to differentiate to get the instantaneous values. So this is not mathematically exact, it ignores the constants in favor of better animation. After all, it's just a visual simulation, =head2 OPTIONS AND ARGUMENTS (-)-h(elp) Help: shows these options (-)-m(an) man : shows this pod (-)-v(ersion) print Modules, Perl, OS, Program info =item B<--version o -v> Prints module && script versions =item B<man> Man: shows these options =item B<help> Help: shows this pod =back =head1 SYNOPSIS Roller Coaster =head1 SCRIPT CATEGORIES fun =head1 OSNAMES any =head1 AUTHOR zentara #http://perlmonks.org/index.pl?node_id=131741# << zentara@zen +tara.net >> ~ Aug 09, 2005 at 15:03 ART (#482340)~ =cut my ($opt_help, $opt_man, $opt_versions); GetOptions( ## EXPECTED GETOPT: ! JUST MENTION THE WORD 'help!' => \$opt_help, 'man!' => \$opt_man, 'versions!' => \$opt_versions, ) or pod2usage(-verbose => 1 ) && exit; ## EXIT WITH SOME INFO pod2usage(-verbose => 1) && exit if defined $opt_help; pod2usage(-verbose => 2) && exit if defined $opt_man; if(defined $opt_versions) { print "\nModules, Perl, OS, Program info:\n", " Pod::Usage $Pod::Usage::VERSION\n", " Getopt::Long $Getopt::Long::VERSION\n", " strict $strict::VERSION\n", " Perl $]\n", " OS $^O\n", " TkRolerCoaster.pl $VERSION\n", " $0\n", "\n\n"; exit; }
Then it looks more professional, don't you think so?

Thank you!

{ \ ( ' v ' ) / }
( \ _ / ) _ _ _ _ ` ( ) ' _ _ _ _
( = ( ^ Y ^ ) = ( _ _ ^ ^ ^ ^
_ _ _ _ \ _ ( m _ _ _ m ) _ _ _ _ _ _ _ _ _ ) c h i a n o , a l b e r t o
Wherever I lay my KNOPPIX disk, a new FREE LINUX nation could be established

In reply to Re: ztk-roller-coaster-simulation by chanio
in thread ztk-roller-coaster-simulation by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found