Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Games in Perl

by artist (Parson)
on Jan 10, 2002 at 03:50 UTC ( #137620=perlquestion: print w/replies, xml ) Need Help??
artist has asked for the wisdom of the Perl Monks concerning the following question:

Recently I developed interests in Games, mainly the shockwave / java games.
Would like to know if where I can find more information about game developed in Perl. Doesn't need to be CGI games. Perlscript games are OK too.

. Thanks,

Replies are listed 'Best First'.
Re: Games in Perl
by jepri (Parson) on Jan 10, 2002 at 04:24 UTC
    At the moment it is difficult enough to do any form of graphics in perl, like displaying menus or buttons (no more difficult than in C, but that doesn't make it easy). Part of this problem is the not-crossplatform nature of graphics. As of a month ago, I was unable to find a interface to any 2D or 3D graphics engine for perl.

    The best hope you have for graphics engines is to write a wrapper or interface to an existing engine like Nebula or Crystal Space.

    However, Perl excels at being a server for distributed games, and there are a number of MOOs, MUDs, MUCKs and MUSHs not to mention many many CGI games that demonstrate this.

    Nebula in particular looks very good for hitching up to perl. Unfortunately the last release was a year ago :( It's not terribly well documented, and half of that is in German.

    I didn't believe in evil until I dated it.

      I mostly agree, but what's wrong with Perl/Tk, what with its GUI widgets and Canvas for drawing stuff on? Of course, while you might have fun in Tk with vector drawings and static bitmaps (remember how we all loved mostly low-rez Wizardry on our Apple IIs?) you probably won't find an interface to OpenGL in Perl. Oh wait. You will. *grin* (and no, I've never used it, so I can't actually say that it's worth a look).

      And if those engines exist with C interfaces and you gots skillz, maybe you'll be the hero by writing the XS to make them accessible to Perl. But frankly, I doubt a scripting language is a good place to write "action" oriented games with polygonz running all amok. But Perl makes a great place to implement an interface to GNU chess or a networkable or mildly AI'ed strategy or card game.

      Besides I seem to recall a recent article I read where the most popular computer games were Minesweeper and Solitaire, so maybe the interface isn't that big of a deal.
        Tk was kinda what I was referring to above. It's OK for basic stuff, but even GTK+ ain't got great gaming libraries.

        I pumped Nebula a little bit because it is a combination of fast C and easy to use Tk - could just as easily be perl. The Tk does the high level scene arrangment, and the C makes it go fast. Quite cool.

        I didn't believe in evil until I dated it.

      But you're forgetting gtk-perl!!! ;)

      It currently has support for all gtk+ 1.2 widgets, much of GDK, libgnomeui, and a few other things. It's worth checking out as a GUI for non-3D games.

Re: Games in Perl
by gri6507 (Deacon) on Jan 10, 2002 at 06:53 UTC
    In the past, I have written some basic "board" games like tetris,minesweeper, and tic-tac-toe in Tk. You can find the code for tetris at here. This page is a Tclet game, but also contains the Perl/Tk version. I have found that for games like that even my beginner Tk skills were adequate.

    More recently, I became interested in doing simple 3D graphics in Tk. Even thouhg most low-level 2D support is existant within the canvas widget, when 3D applications are involved, the display slows down for even something as simple as a rotating cube. (Mind you, my 3D abilities are very rudimentary, and I am sure that optimization is in order). I would certainly be interested in playing around with what I have so far to see how much I can push Tk. I would be very interested to see what, if anything, you have achieved so far.

      Hi gri6507,

      I too am messing around with 2D and 3D graphics
      in Perl/Tk. What I want to know is have you been
      able to get around the "flashing" problem when
      animating things on the canvas.

      Any suggestion or moral support welcome.

      Its like a dog that can sing and dance.
      It's remarkable because it can do it.
      Not that it can do it well.
        I am not sure which "flashing" problem you are talking about here. If you are talking about refreshing objects then I have a few quick suggestions:

      • if it's a repeated movement use $mw->repeat() function wish short timeouts (like 100ms) and have your routine move the object(s) a little bit at a time.
      • Try not to move EVERYTHING. Move only the things that in your scope of view.
      • Put more RAM into your computer.
      • I hope this helps. If you have any more questions, feel free to drop me a line.

Re: Games in Perl
by toadi (Chaplain) on Jan 10, 2002 at 14:01 UTC look at this link. This will provide you a multimedia library SDL(like directX but crossplatform); this particular site provides the perl bindings to that library :)

    My opinions may have changed,
    but not the fact that I am right

Re: Games in Perl
by theorbtwo (Prior) on Jan 10, 2002 at 04:35 UTC

    In addition to the stuff mentioned above, for realtimeish games (which is many of them), perl can be terribly slow.

    For that matter, even C can be terribly slow; they often have handwirtten assembler for the more time-sensitive parts, even with hardware graphics rendering.

    Also, perlscript has a very small audiance -- AFAIK, it's only usable on IE with ActiveState perl installed.

    James Mastros,
    Just Another Perl Scribe

      Actually PerlScript can be used server-side as an ASP language for IIS or PWS. Unfortunatly, I don't see much use in ASP for gaming. Perl programs can be converted to Active X controls with ActiveState's PerlCtrl, but I've never tried that. I'm not a big Active X fan.

      There are some fairly simple Tk games out there, This site has more information on Tk Games.

        I stand corrected. (OK, sit corrected, if you want to be technical.)

        James Mastros,
        Just Another Perl Scribe

Re: Games in Perl
by $code or die (Deacon) on Jan 10, 2002 at 15:45 UTC
Re: Games in Perl
by Torgo (Beadle) on Jan 10, 2002 at 22:31 UTC
    Yeh, if you're talking about web-based games (and I assume you are) Perl doesn't make a good front end. Perl can, however, make a good back end, managing users and global high score lists or whatever.

    Here's two games I've written with a JavaScript front end and a Perl back end:
    Bubble Crack (kinda big)
    Burster (kinda old)

    Incidentally, If you are interested in doing the front end in JS, I've written a cross-platform, cross-browser library for dealing with layers:

    I write the code while the master is away!
      can anyone make me a dice game where when they win it adds the amount of token winnings to the tokens they already have? Thanks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://137620]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2017-06-26 09:35 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (575 votes). Check out past polls.