Developing Games with Perl and SDL 248
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."
Hmmmm.... (Score:5, Interesting)
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++?
Re:Hmmmm.... (Score:3, Informative)
Because much of the complexity new developers run into is baggage from the Operating System and the Development Environment.
And YES Linux is just as guilty as Windows is these days.
Re:Hmmmm.... (Score:4, Insightful)
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?
Re:Hmmmm.... (Score:2)
Maintainability. But you're right for a game that pretty much doesn't matter. For business applications, there's a point to not encouraging VB apps - who knows when Microsoft will discontinue various versions of the language.
Re:Hmmmm.... (Score:2)
Re:Hmmmm.... (Score:2)
Re:Hmmmm.... (Score:2)
Re:Hmmmm.... (Score:2)
I remember when I first learn Z80 assembler I wanted to move a sprite
in screen 2 using the arrows keys, because it was too damn slow in BASIC.
The result was that it was just too fast to follow.
Good days
Python has been used for this. (Score:2, Informative)
Re:Python has been used for this. (Score:5, Informative)
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.
Re:Python has been used for this. (Score:4, Interesting)
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.
Re:Python has been used for this. (Score:2)
Re:Python has been used for this. (Score:2)
Re:Python has been used for this. (Score:3, Insightful)
Re:Python has been used for this. (Score:3, Insightful)
They are both excellent languages, and if you're of the ill-informed opinion that one or the other does not serve well for large, highly strucutred projects, then I suppose our experience
Panda 3D (Score:2, Informative)
http://www.panda3d.org/ [panda3d.org]
And a little "Hello World" to show you the pwoer of it is at:
http://www.panda3d.org/wiki/index.php/A_Panda_%22H ello_World%22 [panda3d.org]
Peace,
-Nick
Re:Python has been used for this. (Score:2, Funny)
Re:Python has been used for this. (Score:2)
Out of curiosity, what problems have you run into? I'd be glad to give some pointers since I've done a decent amount of work with Python in places where shell scripts would normally be used.
Re:Python has been used for this. (Score:2)
Ouch. That's actually a little more advanced than what I've done and would really depend on your ability to interpret terminal-type specific special characters. I'd actually be interested to know how you do this in Perl too. I'm guessing that there's a CPAN module for this sort of thing?
I'll have to give this one some thought. Unfortunately, I don't have access to P
Re:Python has been used for this. (Score:2)
http://wiki.python.org/moin/OrganizationsUsingPyt
You might want to read the rest of that page too.
A 286 Emulator? (Score:2, Funny)
No, thats what flas is for. (Score:3, Informative)
Wait a minute (Score:5, Funny)
I thought perl was already a game.
Well, duh! (Score:3, Insightful)
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....
Re:Well, duh! (Score:2, 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
Re:Well, duh! (Score:2, Insightful)
Oh, and scripted languages' memory management saves exactly zero development and testing time over non-memory-managed languages, too, while simultaneously not helping you at all to avoid me
example game (Score:5, Informative)
Re:example game (Score:2)
Re:example game (Score:2, Informative)
Re:example game (Score:2)
Re:example game (Score:2)
Hmm (Score:2, Insightful)
Tetris puzzle games, or c64 style games. (Score:3, Insightful)
SDL+PERL can be thought of a 'flash killer' hack.... with enough specific libraries for sdl in perl, they
could do extra tricky bits animated mpeg1 in a sprite with one command.
Re:Hmm (Score:3, Insightful)
Perl itself is slow....
I keep seeing statements like this, and I wonder what they mean.
I have used Perl fairly extensively in data mining and format conversion work, sometimes using the Tk extension to provide a GUI front end, but I don't do real time applications or games. However I expect Perl would be adequate for many games, because I think that a lot of people are not recognizing the difference between a scripted language and an interpreted language.
Perl is a script language that is compiled on
Re:Hmm (Score:2)
Frankly I am interested in trying out this new library. It would be pretty cool to get some graphic bang for my perl buck.
Re:Hmm (Score:2)
That means for tasks that are computation intensive, Perl is something like 100 times slower [debian.org] than a natively compiled language like C. Now if your project is mostly I/O bound, then it might not really matter how fast your language is, since you spend most of the time waiting for disk or user input.
Re:Hmm (Score:2)
Well, I would say that anything but Assembly is slower than C.
a good C compiler brings the compiled code as close as possible to an optimized assembly code. You just cant beat that unless you have a well optimized assembly or a poorely written C code.
Not anything new (Score:2)
Personally, I think lua would be a much more interesting choice than perl for this.
Re:Not anything new (Score:2)
Lua would be a good one though. It's found quite a little niche for itself in games as it is so easily embedded into a parent program. Lua would be a more relevant skill than perl for somebody looking to get into working in games. (IMHO)
Re:Not anything new (Score:2)
There speaks a programmer who has never used INTERCAL.
Re:Not anything new (Score:2)
It's a matter of taste. The only advantage of python IMO is that it comes with an standardized and large set of libraries.
This is not actually an advantage in every situation, though. And there's also plenty of libraries available for lua, only there is no standard package thereof.
Re:Not anything new (Score:2)
Yeah, that's the problem with lua. I think it will improve a lot from now on though, first because there's already a fair amount of useful libraries available for lua, and second because lua 5.1 has a s
Games in Perl? (Score:2, Funny)
Enhancing gui user experience with Oracle Forms
HowTo: Brute Force numbercrunching in Visual Basic
or
Windows 98 Security 101
Re:Games in Perl? (Score:3, Funny)
Any game will do!
In return, I will give you a number crunching program in Visule Basic. Unfortunately, the only number it crunches is '4' :-)
Re:Games in Perl? (Score:2)
Do you have a copy in any linux compatible language?
I had no idea how freaking many 4's I have. This could really get to be a problem soon....
darby@gentoo_laptop ~ $ slocate 4 | wc -l
74714
Low level 2d game libraries are so 1990's ... (Score:3, Interesting)
So, sit down on your bums and write a Perl API for DirectX with good WINE support, folks. ;-)
Re:Low level 2d game libraries are so 1990's ... (Score:2)
Or invest in Torque3D.
Re:Low level 2d game libraries are so 1990's ... (Score:2)
Okay:
a) Not every game needs to be 3D. This attitude is why gameplay has languished in the name of pretty graphics.
b) With the continued success of things like the GBA, it's clear that there's plenty of interest in 2D games.
c) The general approach to making games is the same, whether 2D or 3D. Perl+SDL creates a low-
Re:Low level 2d game libraries are so 1990's ... (Score:2)
PyGame (Score:2, Informative)
Why use Perl when you can use Python?
Re:PyGame (Score:2)
Re:PyGame (Score:2)
This is no longer true, and hasn't been for years.
Re:PyGame (Score:2)
Re:PyGame (Score:3, Informative)
Whilst read-write access of closures would be nice, it's trivial to get around this. It's certainly not enough to get me to switch back to Perl - yuck! No thanks! I like my well-defined object model
IIRC Ruby has read-write closures? Why not use tha
Re:PyGame (Score:3, Informative)
How is it not a problem with lexical scoping? The assignment is ambiguous because of the way lexically scoped variable declarations (don't) work in Python. Whether this is a problem with lexical scoping itself or the syntax of variable assignment in Python is really a meaningless question, since it's a problem resulting from the combination of the two. Definitional questions aside, I don't want to work in a language with "incomplete" closures when there are better alternatives.
Perl has a perfectly well-de
Re:PyGame (Score:3, Informative)
Because the scoping itself works fine. The problem lies with variable assignment and declaration in Python being ambiguous when dealing with multiple scopes. This means that closure support in Python is incomplete, in that closures are essentially 'read-only', in that inner assignments won't work. This can be overcome with mutable types, but I agree that this isn't a ideal solution.
This is why I say incomplete, and not broken. By the same standards, I say tha
Re:PyGame (Score:2)
Because the scoping itself works fine. The problem lies with variable assignment and declaration in Python being ambiguous when dealing with multiple scopes.
But if the syntax for assigning variables doesn't work nicely with lexical scoping, I think it's reasonable to say that something to do with lexical scoping isn't working properly. If Python would change it's lexical scoping rules slightly, the problem would be fixed without changing the assignment syntax. (Essentially, you could have the system work
Re:PyGame (Score:2)
I think it might be a case of programming style. I used Perl for years before I discovered Python, and I find myself liking the latter a lot more. But then, I've always taken a very
Re:PyGame (Score:2)
Python is my scripting language of choice but I would never claim that Python's OO approach is even remotely clean. Example:
The result, of course, is that Python prints "Bad". Python has a prob
Re:PyGame (Score:2)
Let's take the following Python code:
The class 'A' is instantiated into a new object, which is placed on the heap. The constructor 'A()' returns a reference to this new object, which is stored in the variable 'ob'. Note that 'ob' stores not an object itself, but merely a reference to one. All variables in Python are references to objects, withou
Re:PyGame (Score:2)
Object methods have complete lack of contextual identity within their instance. The same closure rule that causes problems with variable scoping extends in a non-sensical way to Python objects, such that Python never checks to see if a variable is outside a method's scope but inside the object's sc
Re:PyGame (Score:2)
I have to disagree:
The 'foobar' method knows exactly which object it belongs to. That seems a very solid grasp of object identity to me.
Re:PyGame (Score:2)
Re:PyGame (Score:2)
"When last I looked, Perl didn't treat scalars, hashes and arrays as objects. Perl's incomplete object model is, in my view, a far bigger problem than Python's read-only closures. And on the subject of things Perl doesn't have, as far as I know, it has no metaclass support, either."
All true (except for the opinion about severity which is simply an opinion and neither true nor false).
While Perl 6 endevours to add
Re:PyGame (Score:2)
Because arguments, when intelligently debated, often offer previously insight to both sides. It's a competitive exchange of ideas. Whilst I can't comment on what brpr thinks, his arguments have made me think more carefully about Python closures and scoping, and has opened up some fascinating avenues of thought.
True lexical scoping seems, to me, to blur the distinction between a function and an object. Such r
Re:PyGame (Score:2)
They are if you bless them. Perl's object stuff is weird, for sure, but with some stupid boilerplate code you can ignore most of it.
Re:PyGame (Score:2)
zzzz.... Thats the poorest argument I have ever seem about perl's OO implementation.
Why does an OO language needs to implement scalars, hashes and arrays as objects to be a trully OO language?!?
Re:PyGame (Score:2)
I didn't say this. I said Perl had an incomplete object model. Since scalars and such aren't naturally objects in Perl, not all data types in Perl are objects. Therefore, Perl's object model is incomplete. QED.
Don't forget Common Lisp! (Score:2)
What about all the libraries SDL is missing? (Score:5, Insightful)
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?
Re:What about all the libraries SDL is missing? (Score:3, Informative)
http://www.libsdl.org/libraries.php [libsdl.org]
There is even an SDL based opengl render target.
Tommy.
Re:What about all the libraries SDL is missing? (Score:2)
Perl SDL::OpenGL is lacking some functions, such as primitives to draw spheres and other geometry from GLU and GLUT. Some of the functions are available. I was able to draw a nurb surface and use hardware OpenGL acceleration and get 60 fps from a perl script. But it was at most 50% the performance of C/C++ without all the functions, making it very difficult to make a game. Maybe one of perl's other OpenGL libraries would work better. If so I'd suggest just using SDL for keyboard, mouse and j
Re:What about all the libraries SDL is missing? (Score:2)
Finally! (Score:4, Insightful)
PyGame, different language same idea (Score:3, Informative)
It's basically a wrapper for SDL that makes it extremely easy to make games with Python. You could easily make a working 2D game with sound and decent physics in an evening if you are already familiar with the language. I'm a relative newb, and even I was able to make a basic pong/breakout type game in a few nights. :)
Or use PyOpenGL [sourceforge.net] and you can make some 3D games.
Other languages (Score:2)
[puts on flame suit] This is going to be controversial I know but has anyone tried developing a real game in Java? (by real I mean something that you don't play on a mobile phone) I realize that the GCing could be problematic but it is possible to minimize or even eliminate that problem. Other than that I think the language is probably fast enough now and I would have thought that the lower development time would encourage games houses. Perhaps it's simply that the tools aren't there for Java yet (maybe the
Re:Other languages (Score:2, Interesting)
Jake2 [bytonic.de] (Quake 2 clone) as the AC already posted.
Puzzle Pirates [puzzlepirates.com]
Tribal Trouble (good!) [tribaltrouble.com]
check out javagaming.org [javagaming.org] for tons of discussions about the subject.
and tools? how about:
LWJGL: http://www.lwjgl.org/ [lwjgl.org]
JMonkeyEngine: http://www.jmonkeyengine.com/ [jmonkeyengine.com]
Xith3D: http://xith.org/ [xith.org]
And there are probably tons of other games and tools I'm forgetting.
And regardless what the trolls will say, it is perfectly possible to create a 2006-level game in java.
Quick Prototyping... (Score:2)
As for this, I suppose it's nice enough. I don't see what it brings to the table that hasn't been done many times before, in many different languages, but making games is fun en
If you want to make money... do it with Java... (Score:2, Interesting)
Nicely done tutorial! (Score:2)
what platform? (Score:2)
Nitpick (Score:2)
Re:Fine for simple games but... (Score:2, Informative)
Re:Fine for simple games but... (Score:5, Interesting)
Re:Fine for simple games but... (Score:2)
highly optimised C with a few dozen lines of perl wrapper, why
bother with Perl in the first place?
Easy (Score:5, Insightful)
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.
Re:Easy (Score:5, Informative)
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.)
Re:Easy (Score:3, Interesting)
Re:Easy (Score:3, Funny)
But you also need to remember that the remaining 80% of the code takes the other 80% of the time.
Re:Fine for simple games but... (Score:2)
(They can still be fun, though. Two amusing games, mortal szombat and frozen bubble, were written in perl as I recall. But they are both clones of old games on other platforms)
There is a way h
Re:Fine for simple games but... (Score:2)
Re:Fine for simple games but... (Score:4, Insightful)
Re:Fine for simple games but... (Score:2)
Eivind (Perl Must Die!)
Re:Fine for simple games but... (Score:2)
Nothing to do with pride. I do a harmless post and along comes
one of the standard issue slashdot yaboosucks crowd who do
nothing except make failed attempts at putting down others
because they think they're being standoffishly intellectual.
Its a bit sad.
>By the way, the tone of your reply is sarcastic.
One step up from his then.
Re:Fine for simple games but... (Score:2)
If you want a sophisticated AI, go find a program that plays Go at a master player level.
Re:Fine for simple games but... (Score:2)
Re:Fine for simple games but... (Score:2)
Re:Fine for simple games but... (Score:2)
To the best of my knowledge, no such Go AI exists.
Re:Fine for simple games but... (Score:2)
Re:It'd be nice if there was just an OS C/C++ "bas (Score:4, Insightful)
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?!