Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Game programming using SDL and perl?

by moodster (Hermit)
on Apr 12, 2002 at 13:47 UTC ( #158572=perlquestion: print w/ replies, xml ) Need Help??
moodster has asked for the wisdom of the Perl Monks concerning the following question:

Anyone remember Bombuzal? It was a clever little puzzle game where you walked around and tied to set off bombs. When a bomb exploded, it would also ignite other bombs nearby, so the trick was to find the correct order of blowing 'em up without getting hurt or cut off from the rest of the playing field. I loved it and played it for ages on my C64.

But enough nostalgia. The other day I got into my head that coding an open source clone of the original Bombuzal would be both a) a good learning experience and b) a way to give back something useful to the community. Cool! I always wanted to be a game programmer.

The game itself is relatively simple; no fancy graphics (I could probably do them myself using gimp or POV-RAY or both), and no need for top-notch performance. So I'm starting to wonder if I shouldn't try to do this in perl and SDL. The problem is, I haven't really messed around with SDL or tried to use perl for game programming, so my questions are:

  1. Is perl a good choice for this type of project? Can I expect things to run smoothly? I won't do any 3D-rendering requiring 50fps, I just need to draw some tiles and let the player walk around on them.
  2. Is perl-SDL a good choice or are there other packages I should check out? I know there is a game programming framework for python called PyGame. Is there something similar for perl?
  3. Using perl and SDL, what kind of cross-platform performance can I expect? Will I be able to run on MacOS X and Win32 without problems?
PS. This would all be so much easier if it'd been possible to Super Search for 'SDL', but right now it only accepts search terms containing four letters or more, alas. DS

PPS. If you check around a bit using the link above you'll be able to download the original PC (and/or C64) version of the game. Try it! DS

Cheers,
--Moodster

Comment on Game programming using SDL and perl?
Re: Game programming using SDL and perl?
by Molt (Chaplain) on Apr 12, 2002 at 15:04 UTC

    Disclaimer: Not done SDL with Perl, but done SDL with C++, and oddly enough have done Perl without SDL. I'm answering this based on my knowledge of both, and assuming a fairly competent XS-based interface.

    SDL is quite nice, and allows a fair range of use. For what you want I think it'll be more than capable of handling it, and you could probably even do a fair bit more advanced stuff with it should you wish. The performance hit from doing Perl rather than C++ should be more than absorbed by the fact you're not doing umpty-thousand element particle effects, and other such heavy-duty 3d stuff.

    Sounds a nice way to get into games programming, and it'll be nice to see more games in Perl. It's always best to start off trying to do something you can finish rather than some huge blue-sky thing which'll never see the light of day, if you'll pardon me mixing my metaphors.

    Good luck with it, and keep us updated.. I for one am curious as to how this goes.

Re: Game programming using SDL and perl?
by {NULE} (Hermit) on Apr 12, 2002 at 22:53 UTC
    Hey Moodster,

    Interesting idea. Much like Molt I've played with SDL but only in C/C++ (Programming Linux Games by John R. Hall is a great book IMO). I didn't even know there was a Perl SDL API until this post, otherwise I would have looked into it long before now.

    I've always wanted to combine Perl into games programming because of its maintainability and flexibility and ease of coding. Plus it is a relative piece of cake to embed it into an engine. My thought was always that I'd write a C++ engine but that various subsystems could call Perl for things like player AI, networking, game logic, but C++ would do the heavy lifting for OpenGL, sound, etc. This sounds like an exciting alternative.

    Sorry that I can't offer any "I've been there or done that" advice, but it sounds like a good plan and I'm sure it will be fun. And thank you so much for bringing this idea up - now I have something new to play with too. :) Definitely check out the PLG book from No Starch publishing too. It is a good overview of SDL and a good overview of game design in general.

    Update: You're probably aware of this Moodster, but for learning about using an embedded Perl interpreter do a perldoc on perlembed. I haven't tried it myself, but it doesn't look too terrible to work with.

    Good luck,
    {NULE}
    --
    http://www.nule.org

      Now that's an interesting thought. I've been thinking about how to package this app to make it easy to install even for non-programmers. Ideally, the user should not need to have a perl interpreter installed on his/her system, and as I understand it, there are ways to do this (have to re-read Programming Perl again).

      Embedding perl code in a C++ application might be an alternative as long as I don't have to sacrifice cross-platform functionality. Also, it'll give me a chance to brush up my C++ a bit, which is nice.

      I must admit that I like python a lot because of it's syntax and OO-capabilities. But I think I'd rather use perl for this...

      Cheers,
      --Moodster

        It is always a good idea when developing big games to keep the things outside the core nice and scriptable, it makes them a lot easier to change and also allows external developers to more easily bang out things like the Quake mods, TCOs, and even the huge Baldur's Gate add-ons which are freely available

        Perl should be a nice plugin language for scripting though, and with XS for your C++ integration (And Inline::CPP for your quick tests) you should be able to manage wonders.

        There is a nice tutorial on developing your own 'little language' for scripting in the Tutorials section of Flipcode. Whilst it probably won't help you with the technical implementation it will give you a nice overview of some considerations which you may otherwise overlook. It's the 'Scripting Language Tutorials Series', and it's worth a quick look at least in my opinion.

Re: Game programming using SDL and perl?
by ncw (Friar) on Apr 13, 2002 at 08:28 UTC
    I think SDL would be ideal for writing an old 8-bit style game. In fact I used it for exactly that a while back porting a game I wrote in 1991 to run on Windows and Linux. If you were brought up in the 8-bit era then SDL brings back some of the visceral thrill of poking things to the screen and fiddling with the colour map!

    I haven't tried SDL in perl (only in C) but I note there is what looks like a comprehensive set of bindings here - SDL. Don't be put off by the huge number of things you can do - like any good API it is very wide and shallow. Just make a screen and get poking!

    SDL itself runs fine on many platforms as I'm sure you know and I ported several SDL programs to windows and linux. I'd imagine if you could get the SDL module to compile on a given platform then your game would run.

    I'm sure perl will be fast enough - after all we used to write this sort of game in BASIC with a smattering of assembler to plot things and you've got SDL to do that.

Re: Game programming using SDL and perl?
by stefp (Vicar) on Apr 13, 2002 at 22:25 UTC
    If you want to check out what can be done with perl and SDL, go to frozen-bubble, a game made by people from Mandrake. Nothing like the French touch. But I am partial here.

    -- stefp -- check out TeXmacs wiki

Re: Game programming using SDL and perl?
by Dr.Altaica (Scribe) on Apr 14, 2002 at 04:36 UTC
    While if your want to use SDL in perl I would suggest cheaching out SDLperl. Any reson you're not useing PerlTk? It's standered on every system I've been on and have geven me good purrformance on my Iso metric 3D RPG so far.
    |\_/|
    /o o\
    (>_<)
     `-'
    <\pre>
      This is probably just bias, but in my experience the Tk widgets are pretty ugly. Are you doing any special customizing of the widgets in your game (I'm not really familiar with Tk coding, so I don't know what you can do with them)? Platform independence is a plus, though.

      I just had a quick glance at http://www.sdlperl.org, but couldn't find much online documentation. I assume this is the web home for the SDL modules on CPAN?

      Cheers,
      --Moodster

        I'm not doing any specal costumization but the game's UI is motly just one big Canvas that the iso-view is drawn in and you can click on things like in Diablo. I'm useing normal scrollbar, buttons, entrys and messages.
        Old code TRansparent Animated gif bug in perlTk? Newer code and a screen shot at YiffieMon CRPG website I guess you could call it ugly but I like it.
        I Don't know much about SDLperl I just happened to come across it shortly befor seeing the quetion and didn't see any one mestion it so thoght I would. I'm quite happy with perlTK so far so I'm sticking with it.
        |\_/|
        /o o\
        (>_<)
         `-'
        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-08-21 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls