Hi Scott and all,
Well, the reason I am currently not using PyGame is that I don't often write a lot of stuff in Python myself. As it happens PyGame is just one of several APIs that use the cross platform SDL libraries. Since SDL is so widely supported by various open source APIs I can pretty much use any programming language I want. for Visual Basic and C-Sharp the SDL API is SDLDotNet, for Python it is PyGame, for Java developers it is JSDL, etc. Weather you use SDLDotNet or PyGame the functionality is the same, because it boils down to the core SDL support on the operating system in question. As far as SDL verses DirectX there are of course advantages and disadvantages. Which you decide to use depends on the game, what you want to do, and so on. DirectX is definitely more widely known, has the superior audio support, and is considered by most to be the best game development API out there. However, that comes at a cost of being more difficult to program, is only really supported on Windows based platforms, and more recently Microsoft has been doing a lot of monkeying around with the DirectX libraries. The current DirectX releases are being merged with there XNA development API to close the development gap between the XBox 360 and Windows PC games. As for SDL its obvious advantage over DirectX is that SDL runs on just about anything including: Mac, Linux, Solaris, Windows, etc. If you plan to target a computer running a non-Windows operating system then SDL seams like the obvious choice since SDL ships with many non-Windows operating systems by default, or can easily be downloaded/installed. Another huge advantage in SDL's favor is the growing number of languages that now support it. Thanks to the open source nature of SDL many third-party developers have created APIs such as PyGame, JSDL, SDLDotNet, and so on that allows you to pick any language you want and start game programming. You can write a game in all sorts of languages using SDL such as: C, C++, C-Sharp, Python, Ruby, TCL, Perl, Visual Basic, etc. This makes it rather powerful in a way DirectX was never designed to do. Perhaps my favorite feature of SDL is that the API itself was designed to be easy to learn, program, and work with for newbies or advanced programmers. The developers understand the keep it simple stupid design rules, and unlike Microsoft they don't go out of there way to make the API complicated to understand or use. What I am saying is that SDL APIs are designed to be newby user friendly. With a language like Python it becomes even more simple to use. I can write a simple sound player program in a handful of lines like this.

#Include pygame libraries.
import pygame.mixer
import pygame.time

#Initialize the default sound buffer
#Set sounds to 22050, 16 byt, mono.
pygame.mixer.init(22050, 16, 1, 2048)

#Load the sound file.
sound1 = pygame.mixer.sound('sound.wav')

#Create a channel object.
channel1 = pygame.mixer.channel()

#Loop the sound file.
channel1 = sound.play(-1)

#Wait 5 seconds.
pygame.time.delay(5000)

#Position sound on the left.
channel1.setpanning(200, 0)

#Wait 5 seconds.
pygame.time.delay(5000)

#Position sound on the right.
channel1.setpanning(0, 200)

While the above program is fairly simple in most languages such as C, C++, Java, etc it would be considerably longer to create the identical program. Obviously Python makes even a simple task easier. However, since I am using an SDL based library it is a fairly straight forward process anyway. An identical DirectX program would be a bit more involved. You have to go through the process of writing your own sound initialization function that sets up the audio device object, sets the cooperative level, and acquire the sound card before you can do anything with it. SDL Mixer doesn't require that much detail to start using it. With all the advantages listed above you might think SDL is really great. There are, however, some things I dislike abut SDL. For one thing in order to position the sounds you have to first create a channel object and asign a playing sound to it. After that you can set the stereo panning on the open audio channel to move the sound left or right. This is different from DirectX which allows you to set the panning on the sound before you start playing it. The problem with SDL Mixer requiring to start a sound before setting the pan effects is that I've had a sound start playing in the center of the stereo field and then jump to the left or right speaker. This is very unrealistic sounding and quite annoying. It is possible I am not doing something correctly, but I'm not too keen on setting panning after the fact. Another thing that SDL lacks is realistic virtual 3d audio effects. Sure you can change the stereo panning to sort of fake it, but it is not, will not, and can not compare to DirectX 3d audio buffers. Like I said I have faked it in my test apps, but still you can kind of tell it doesn't quite sound exactly right. Though, if you are going cross platform it will have to do. There is a diference in the way SDL Input and DirectX input polls devices like keyboards. For purposes of discussion I'll pick on pygame.input. In DirectX you can hold a key down and it will continue recieving input until said key is released. This is good if you want to walk, run, etc without pressing the left/right arrow keys like a mad man. With SDL input the keyboard down event acceps the keyboard press when the key is pressed, but ignores it if it is being held down. There are work arounds for this such as the keypressed function that returns a true/false boolean value which you can asign to a pygame.timer to do some action when the key is being held down, and stop when the key is released.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to