Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Perl TK books

by Anonymous Monk
on Nov 12, 2004 at 01:58 UTC ( [id://407242]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to get into Perl game development, is Perl TK the best way to go about this? Not super complex games necissarily but games with real time graphics perhaps?

If this is the best way to go about this, what Perl TK book do you think is the best? Amazon has a number to choose from. If there's another module that you think is better that does similar things, what is it and what book(s) what you suggest?

I heard that there's a way to turn Perl into exe files so you could give it to people who don't have Perl to run, is this possible?

I have to ask these questions now as I'm preparing my Xmas list! and I get a new Perl or CGI book every year.

Replies are listed 'Best First'.
Re: Perl TK books
by Aighearach (Initiate) on Nov 12, 2004 at 03:16 UTC
    Perl/Tk is very excellent for building fairly fast, very cross platform applications. It's a real pleasure to be able to develop things entirely in my comfy *nix world, and then send them off to my windows friends and have them already work, without any porting. Sometimes I have to tune things to get a pointer icon to be the right color, but that's the extent of it.

    It's not generally as fast as something like SDL. And it doesn't try to be.

    My only game experience with it, is a chess client for internet chess. For something like that, it can draw the arbitrary bitmaps used for the pieces very fast, and the user doesn't notice any speed difference with features like "piece dragging" compared to a native app. So it is very fast for normal GUI types of things, and moving sprites around.

    However the object model is rather large, and again, is optimized for things other than speed, like portability, extensibility, etc. If you're planning on living in the upper half of the graphics capabilities on the users machine, then really don't expect Tk to cut it. Also, when I was doing all the graphics at a low level using Tk::Canvas, it wasn't as efficient as Perl/Gtk when it came to updating only a small corner of the window (that became unhidden). Also, it is prone to creating a flash effect when things are redrawn, IF you are not careful in your coding.

    So my recommendation is, use Tk if you can get away with it! Also, the books suck. :) The docs are okay. The bundled code examples are what I found most useful. Pay particular attention to perldoc Tk::callbacks and Tk::bind in particular the Ev() constructor, which I found to be the most difficult part of the model to understand.


    --
    Snazzy tagline here
Re: Perl TK books
by bart (Canon) on Nov 12, 2004 at 02:08 UTC
    I want to get into Perl game development, is Perl TK the best way to go about this?

    IMHO: no. Take a look at that other Perl game, Frozen Bubble. I think that whatever library they've used, lies more in the proper direction, for graphical games in Perl.

      Apparently, Frozen Bubble uses SDL
        SDL has a very hard time compiling on many platforms (snapshot or CPAN version) in most incarnations. It also has issues with hanging, etc, that are quite a problem.

        Tk is definitely fun to play with, Mastering Perl/Tk is a great book, however I do not think Perl is really a good game development language for 2D. If you can get the OpenGL bindings to work (this may be a toss-up), OpenGL is a fine way to go. However Perl's OpenGL bindings are not well updated and tend to pose problems.

        I've tried many times to make it such, but ultimately it never ends well. While Frozen Bubble is a masterfully beautiful game, the code isn't IMHO, and there is a lot of pixel manipulation and other routines done in extra libraries built on top of SDL. SDL is brutally low level and unforgiving.

        I still maintain that game development was MUCH more fun back when we had GW-basic, simple C pixel routines, and mode 13h. Why? You made simple stuff and it worked.

        OpenGL is fun, but there is a bit of a learning curve. 2D in OpenGL is doable, but sound is a bit of a problem.

Re: Perl TK books
by erix (Prior) on Nov 12, 2004 at 03:16 UTC

    There is also wxPerl. It has native widgets/controls, and is available for several platforms.

      It has a history of not living up to it's cross-platform claims, in fact it often won't even compile on common platforms. I recommend against it strongly.

      --
      Snazzy tagline here
        Thats not true.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Perl TK books
by Ytrew (Pilgrim) on Nov 12, 2004 at 07:04 UTC
    I want to get into Perl game development, is Perl TK the best way to go about this? Not super complex games necissarily but games with real time graphics perhaps?

    Well, first of all, you need to decide what the goals of your project are. For example, do you especially want to make games with graphics in perl because you want to learn more about how perl handles graphics? Or do you just want to make a cool game, by whatever means necessary? Do you want gameplay that's simple yet catchy, like tetris was, or something more complex and computationally expensive, like 3-D adventure games (Doom, Quake, etc.)

    Once you know what you want, then you can decide if Perl::TK can do it.

    Personally, I find Perl::Tk to be reasonably good to work with, but it certainly isn't the fastest graphics system out there. While I definately prefer programming in perl to programming in tcl, I think that Tcl/Tk was easier to learn than Perl::Tk would have been. However, Tcl/Tk is probably even slower than Perl::Tk is. Remember, Tk does a lot of work for you. Only you can decide whether all that overhead is worth it.

    For most "real-time" games, I would not choose to use perl, let alone Perl::Tk. Games tend to be one of those rare kinds of programs where maximizing speed really does matter. Writing efficient code in C. or Assembly Language will allow you write a game that runs much faster than the same game written in perl. The down-side is that you have to write and optimize all that extra code yourself, then debug it. You might not want to spend that much time on the project. So, depending on how much time you want to dedicate to the project,and how fast the code needs to run, perl may or may not be the right language for the job.

    I have to ask these questions now as I'm preparing my Xmas list! and I get a new Perl or CGI book every year. You might also consider a book on general graphics programming, or one specifically on coding for computer games. I heard that there's a way to turn Perl into exe files so you could give it to people who don't have Perl to run, is this possible?

    There is a perl compiler called "perlcc". It's still marked as "highly experimental", but it can compile a simple "Hello, World" program. Then again, the few other programs I've tried have all caused perlcc to crash. Try it, see if you like it, but don't bet your company on it just yet.

    Hope this is helpful,

    --
    Ytrew Q. Uiop

Re: Perl TK books
by matthewb (Curate) on Nov 12, 2004 at 09:37 UTC
    I want to get into Perl game development, is Perl TK the best way to go about this?

    Advanced Perl Programming contains an introduction to Perl/Tk and an implementation of the game Tetris, with discussion.

    It may be that working through this example would enable you to determine the suitability of this platform for whatever it is you have in mind.


    MB
      There was an Oreilly book "Learning Perl/TK" out some time ago. I believe it is out of print however. I did pick up a copy at Amazon.com marketplace for about $7 used. Might be someplace to check out at least.

      Master Perl/TK looks good. I have a copy however haven't had a chance to read it yet. Still ploughing through "Learning Perl/TK".
        I believe "Learning Perl/Tk" is a subset of "Mastering Perl/Tk" (which is why "Learning..." is out of print with no further editions and is occasionally found in bargain bins).
Re: Perl TK books
by csuhockey3 (Curate) on Nov 12, 2004 at 05:48 UTC
    As far as Tk books, Mastering Perl/Tk is an okay book, but if you are serious about game development it might not be the best option. Have a look at this -- it has a bunch of development resources you might find interesting.
Re: Perl TK books
by zentara (Archbishop) on Nov 12, 2004 at 15:21 UTC
    You can make some fast and complex games with Perl/Tk. If you want really nice 2D-animations, look into Tk::Zinc, which is a Canvas with groups, rotations and zooming of groups. Check out my PONG with TkZinc.

    Now you need to go through the hard lesson of learning to re-use widgets, and other aspects of keeping Tk running fast and clean. This is best done by experimenting with code. I keep my Tk skills going by making little games.

    Here is a screenshot of a scrabble like game which you can play over a network thru sockets. You can get it here is you want to see how I did it-> ztk-babel

    As far as books go, Mastering Perl/Tk is still the best. But like I said, your best avenue to learning is to actually start playing with the code. For instance, if you want a canvas based game, setup the canvas, decide how you are going to store widgets( probably in a hash) and get some rudimentary widgets and movement on the screen. Once you see the problems you are facing, then you start to realize what code you will need to implement your game....and like I said, watch your memory use constantly, there are well known pitfalls and fixes when using widgets, especially photo objects.

    Right now I'm working on a network poker game with Tk, so don't think it can't be done. Admittedly SDL is geared up for games, especially for adding sound and zooming. However, Tk may be a better choice if you want to learn and extend your skills to non-gaming data display with Tk. Tk is generally more useful than SDL, in my opinion, but SDL is quite good. Tk is probably better for cross-platform compatibility than SDL, easier to install etc. SDL is a whole mess of different libs to get and install.


    I'm not really a human, but I play one on earth. flash japh
Re: Perl TK books
by Washizu (Scribe) on Nov 12, 2004 at 14:12 UTC
    Great topic. There are a bunch of haters in this thread, but a game is a great way to learn a lot about Tk. I wrote a tetris clone in it about a year ago called Spew. It's like tetris, except as the levels increase the board spins around and zooms in and out. Give it a try (source and compiled windows exe included).

    Download Spew Here

    I use perl2exe to compile the program into an executable file. As far as books go, I usually use information online although I found O'Reilly's "Learning Perl/Tk" to be helpful when I started out. Hope this helps!

    -----------------------------------
    Washizu
    Acoustic Rock

Re: Perl TK books
by Anonymous Monk on Nov 12, 2004 at 04:23 UTC
    Thanks for the comments so far. I don't like the "all the TK books suck" comment, lol, but I like what everyone had to say so far!

    Any answer to my question on making perl scripts into exe's?

      I've used the commercial version of perl2exe with a lot of success, it handles Perl/Tk just fine. THe noncommercial version is fine for devel, but it leaves the perl command dialog laying around for you to gander at... though there are some fixes for that.

      ActiveState has some nice dev tools like, a library for setting/changing tray icons. But I found you can do it with just the Win32 Perl stuff. If you get to that point and need something like that, let me know and I'll grep for it. I don't use it, and don't have access to a windows box to test it for broader release. I did spend a whole week on it, I am happy to give that out because I wouldn't wish Win32 debugging even on my enemy.


      --
      Snazzy tagline here
Re: Perl TK books
by hackdaddy (Hermit) on Nov 12, 2004 at 08:24 UTC
    Perl TK is great; however, while developing a tool prototype for a large well-known wireless company, I ran into issues where IO would block the GUI on Win32. This was in 2003. I am not sure if the IO blocking issue has been fixed currently.
Re: Perl TK books
by dannoura (Pilgrim) on Nov 12, 2004 at 17:22 UTC

    I heard that there's a way to turn Perl into exe files so you could give it to people who don't have Perl to run, is this possible?

    Try PAR.

Re: Perl TK books
by Zippy The Pinhead (Initiate) on Nov 12, 2004 at 04:50 UTC

    Don't do it man!

    If you want to write video games stay away from Perl, Perl/Tk and the Monastery. For one thing the monks won't be very helpful at all.

  • Games in Perl
  • help with Z-buffer algorithm
    ... and may more unhelpful post.

    If you want to write video games. Do it in C, C++, or maybe just maybe Python or Java. At best the Monastery can offer is slacked-jawed yocals pointing at you a saying "Looky dair! Hez a try'n to make one of them thar uppty video-O-games!"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://407242]
Approved by atcroft
Front-paged by sulfericacid
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-06-13 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.