Slashdot Mirror


Developing Games with Perl and SDL

segphault writes "Andy Bakun has written an excellent 20 page guide to game development with SDL_Perl for Ars Technica. The tutorial, which includes extensive code examples and plenty of screenshots, walks readers through the process of building a clone of the original Atari Kaboom! game." From the article: "One of the biggest benefits of using SDL is that it allows portable media applications to be written without having to be concerned with specific implementations of media libraries for each target platform. Bringing Perl into the picture takes the portability one step further, allowing media-rich applications to be written in a high-level language that can be targeted to a number of platforms. While programming using SDL requires knowledge of C and access to a C compiler, using SDL_perl does not. This greatly decreases the amount of time it takes to get something up on the screen and working."

15 of 248 comments (clear)

  1. Hmmmm.... by ObsessiveMathsFreak · · Score: 5, Interesting

    It sounds good as a learning tool. It would be great if budding game coders, especially younger coders, could be given a simpler enviornment in which to begin toying with graphics and sound coding.

    However, it's in Perl. And I really have to ask myself; Do I want to play games coded by people who started programming games in perl?

    But seriously, whenever you code a game, you always end up using a scripting language of some kind. Perhaps this just cuts out that virtual middleman that is c/c++?

    --
    May the Maths Be with you!
    1. Re:Hmmmm.... by Mr_Silver · · Score: 3, Insightful
      However, it's in Perl. And I really have to ask myself; Do I want to play games coded by people who started programming games in perl?

      I would ask yourself, "why do you care what it is written in?". The whole point of playing a game is that its supposed to be enjoyable. The fact that it is written in Perl, C, BASIC, Java or Cobol is immaterial if you enjoy the game.

      Would you suddenly consider Half-life 2, GTA or any other game "rubbish" just because you found out that it was written in a programming language that you didn't like or didn't think would be suited to the task?

      I see a similar thing with people who snub Visual Basic applications. Yes we all know how good or bad VB is at development but if someone has produced a tool using it which does what you want, quickly, easily and at the right price, why does it matter what it was written in?

      --
      Avantslash - View Slashdot cleanly on your mobile phone.
  2. Wait a minute by eclectro · · Score: 4, Funny


    I thought perl was already a game.

    --
    Take the cheese to sickbay, the doctor should see it as soon as possible - B'Elanna Torres, "Learning Curve"
  3. Well, duh! by GreatBunzinni · · Score: 3, Insightful
    While programming using SDL requires knowledge of C and access to a C compiler, using SDL_perl does not. This greatly decreases the amount of time it takes to get something up on the screen and working.

    Yet, it does need knowledge of Perl, another programming language, and access to a Perl interpreter. So, indeed, in the end it needs the exact same thing that is needed to write a game in C or C++. A person needs knowledge of a programming language, knowledge of an API and access to software which will make the program happen. So, having this in mind, wtf is that intended to mean? Sheesh....

    --
    Slashdot, fix your code or at least hire someone who is competent at it to do it for you.
  4. example game by falkryn · · Score: 4, Informative

    http://www.frozen-bubble.org/ example of a nifty game written with sdl_perl

  5. Re:Fine for simple games but... by rheum101 · · Score: 5, Interesting



    ...it's an oversimplification to state that perl cannot achieve the same performance as C/C++ ... where 99% of the time is spent deep within optimized libraries and perl (or any scripting language) is used to initialize and facilitate interaction, then it is quite possible that no material performance hit will result ... only profiling can really reveal this ... ...and perl / PHP / whatever is a MUCH easier on ramp than getting into deep C++ OO structures...

  6. Re:Fine for simple games but... by Vo0k · · Score: 3, Insightful

    Moreover, writting in Perl is fast and easy. You can test your ideas, check if the game would be playable at all, create a working mockup in Perl and finding "not enough raw horsepower" move to C with the "final product". Sure it will take longer than writing everything in C from scratch, but shorter than writing everything in C and then deciding it sucks and abandonning it.

    --
    Anagram("United States of America") == "Dine out, taste a Mac, fries"
  7. Re:Python has been used for this. by Haeleth · · Score: 4, Informative

    Python with SDL (pygame) has been used to write Dungeon Siege (I think that was the game, correct me if I'm wrong) and I liked the result a lot.

    I don't know what game you're thinking of, but it certainly isn't Dungeon Siege, which was written very conventionally in C++ with DirectX. (It was originally developed with OpenGL, but the developers switched to Direct3D later on, possibly because the game was being published by Microsoft.)

    At any rate, certainly neither Python nor SDL was involved at any stage.

  8. What about all the libraries SDL is missing? by master_p · · Score: 4, Insightful

    SDL is "a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer" (quote taken from the SDL web site). What about:

    1) drawing functions
    2) fonts
    3) openGL
    4) file formats
    5) game GUI
    6) sound formats
    7) networking
    8) configuration

    etc?

    there are various SDL-derived libraries that implement, more or less, the above, but they are C/C++ libraries, and the quality varies. Does Perl make it easy to use those libraries?

    1. Re:What about all the libraries SDL is missing? by TommyBear · · Score: 3, Informative

      There are other thirdparty libraries that offer this kind of support:

      http://www.libsdl.org/libraries.php

      There is even an SDL based opengl render target.

      Tommy.

  9. Finally! by jalefkowit · · Score: 3, Insightful

    At last we can have Tetris with regular expressions.

  10. Easy by Andy+Dodd · · Score: 4, Insightful

    All that highly optimized C is part of a prewritten library (as is the case here).

    For the remaining non-performance-critical stuff, Perl is often MUCH easier to develop with.

    And in many cases, keep in mind the 80/20 rule of thumb. 80% of the time is spent in 20% of the code. This does vary, but in many cases the amount of highly optimized code needed for good performance is very little.

    Many years ago, I was writing a program in Perl. I knew that there was a good chance I'd have to rewrite some of it in C eventually for decent performance, and this turned out to be true. In the end, I obtained 20-40 times the performance (and most likely 95%+ of the performance I would have obtained using C only) by rewriting approximately five lines out of 100-200 lines of Perl in C. The time it took me to figure out how to interface C and Perl (doing so was not documented very well then, it took me 2 weeks to find SWIG) was still far less than the time it would've taken me to write the entire program in scratch using straight C.

    --
    retrorocket.o not found, launch anyway?
    1. Re:Easy by Junks+Jerzey · · Score: 4, Informative

      And in many cases, keep in mind the 80/20 rule of thumb. 80% of the time is spent in 20% of the code. This does vary, but in many cases the amount of highly optimized code needed for good performance is very little.

      That rule of thumb quite often doesn't apply to video games, at least high-end, complex video games. In such, you often see a flat profile, where the work is divided among a large number of functions, none of which stands out as a huge time sink.

      (That said, I still think writing games in languages like Perl is a good idea.)

  11. Re:Python has been used for this. by monopole · · Score: 3, Interesting

    The neat thing is that PyGame is very fast. I've used it to implement tricky realtime cluster rendering for 3d monitors as well as frame accurate animations for temporally multiplexed displays.
    The nice thing about Python is that since it is bound to just about everything it also supports some very fast and powerful 3d engines such as VTK, OSG, and Delta3d.

  12. Re:It'd be nice if there was just an OS C/C++ "bas by petermgreen · · Score: 3, Insightful

    what really gets me is when you wan't to make some changes to open source software (particularlly windows stuff) and sure you can download the source but you have to spend hours messing arround trying to get the build environment right.

    how the hell are users supposed to fix bugs that annoy them if they can't get the build environment right for the existing code?!

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register