P is for Practical | |
PerlMonks |
Lunar Lander (Re: Games in Perl)by rje (Deacon) |
on Jan 10, 2002 at 23:17 UTC ( [id://137823]=CUFP: print w/replies, xml ) | Need Help?? |
This is a silly script, but I love it because it's perl,
and perl is cool. Remember how you coded games before
you had graphics? So what if the screen resolution is
based on your tty? So what if the graphics set is ASCII?
Why should that stop you? Development time sure is faster
than working on a GUI. Of course, scripts like this might have a limited audience... The Lunar Lander is actually a suite of 4 perl scripts, written to run in a UNIX environment. It takes unfair advantage of the UNIX system process ps() to provide control to the lunar module.
To play: place all four scripts into a directory. Open up one terminal window for the lunar module and one window for the user input. Run lander.pl in the first tty. If your tty is not 25 rows by 80 columns, specify your view like so:
To fire one of the lander's rockets, run one of the other commands: h to move left k to move up l to move right What these tiny scripts do is just pause for a fraction of a second -- enough time for the lander script to detect their presence via ps() and fire the appropriate rocket. I know: it's an absurd, kludgey misuse (abuse?) of a perfectly good UNIX command. But it was fun to write. rje P.S. There's quite a bit of room for performance improvement and expansion... for instance, there are no obstacles... h: k: l: lander.pl:
Back to
Cool Uses for Perl
|
|