Game cross-compiling and packaging
Some friends and I wanted to develop a game. Any language will do. I've been programming in C for years, but never wrote a game before. One of us knows SDL a little bit. It would also be a nice excuse to learn Python+pygame.
We wish our game to be 'standalone'. By standalone, I mean most users (at least Linux, Mac and Windows) will not have to manually download and install anything el开发者_如何学Pythonse apart from a package. It is ok if the installation automatically handles missing dependencies. If the packages contain binaries, we wish to be able to generate them using cross-compilation from Linux.
How should we package and structure the project, and what language is best suited?
If you haven't programmed a game before, I'd recommend that you start with Python and Pygame. Python itself is very easy to learn if you're already a programmer, so that won't be too much of a leap for you.
With Pygame, you spend almost no time writing "glue" or dealing with mundane low-level details like window management and sound setup - you'll almost immediately be programming game logic and in no time you'll be blit
ing left and right. What's more, it'll be very easy to get a prototype of your game running so you can start experimenting with the mechanics - I've programmed a simple little side-scrolling platformer in a matter of hours.
Performance
The performance of Python with Pygame is normally decent for simple games, though "smooth-scrolling" games can show poor performance, especially on Linux (in my experience, at least - pygame.display.update()
literally took 15-30ms per frame on Linux, and 4-5 on Windows with cheapo Intel graphics, though this was two years ago and the Linux Intel driver has improved of late). In addition, if you have physics/math-heavy code Psyco can give you huge speedups (20% - 200% in some cases), though you'll be limited to 32 bit Python on x86 computers.
Once you get most of the game logic worked out, if performance is still unsatisfactory, you could switch to C and SDL. Since you've already written the game logic, you'll just have to focus on dealing directly with SDL. Even that should be fairly easy - Pygame internally uses SDL, so the translation should be relatively straightforward.
OpenGL
Unfortunately, the above is only true if you're writing a 2D game - Pygame gives you basically no help for OpenGL. However, I would not recommend starting game programming with OpenGL. It can be pretty difficult to understand at first, so you'd be presenting yourself with two problems at once - first, you're trying to figure out how to get the game logic/physics/ai/etc. working, and then you're struggling to understand OpenGL. It is worth it to learn OpenGL eventually, but not to start with - better to start with the basics and go from there.
Cross-Platform Considerations
As far as cross-platform concerns - py2exe (for Windows) and py2app (for Mac) allow you to build individual executable files that include your dependencies (including the Python interpreter and Pygame); however, I do not think you'd be able to build your executables from a Linux environment (you'd have to be able to borrow a Windows/Mac computer for a few minutes, probably). For Linux, you'd probably just distribute a .deb that lists Pygame as a Dependency (and Psyco as a Recommends or Suggests if necessary).
Have a look at Ogre; it's the engine behind Torchlight. It supports Windows, Ubuntu, MacOS and iPhone.
You may also want to read Gamasutra: their articles, interviews, in-depth and post-mortem analisys provide a very interesting insight in the game development process.
It greatly depends if you want to build a whole game including the engine, or just building upon an established game engine. Although building a whole engine includes much more overhead and hard work, it gives you tons of experience.
Now if you want to create a game engine, the language for the job is C++ (C can also work, I just like C++ better)
For a build management tool, I have found that using CMake is a great option, it manages your build for you on several different platforms, and it can also even create the installers, and install any required libraries.
As for libraries go, most of your problems will be solved by SDL, it is not particularly pleasant to work with, but It manages the headaches of cross platform interfacing with video(OpenGL), Windowing, Input and Audio. You will still need to learn OpenGL to use it in your game, SDL only handles the initialization and setup.
Now for using Python, I would not recommend it, unless your game is simple (2D, or simple 3D without heavy physics usage), because the ammount of overhead incurred by Python will start to eat into your framerate. For a light, scripting language, Lua is definitely the best, it is simple, flexible, and fast. To integrate it, if you want a simple solution, use LuaBind, but beware! Be very selective on where you use it, for it can utterly KILL your compile times!
i would suggest that you develop it On QT... QT will handle most of the portability issues itself... so you don't have to worry about it, plus it supports most of the platform including mobiles... and QT also has very good native support for gaming (Graphics,UI,Sound Controls.. )
Please see application Built in QT
I presume that your game is a 3D one. If yes, than you need OpenGL. It's C, so you'll be familiar with the syntax, but the approach is a bit different, due to the fact that OpenGL is a finite state machine. More on this topic here.
OpenGL is basically built-in on every platform, so you would only need to initiate a single full screen window and let OpenGL handle the drawing. For cross compilation, I would recommend wxWidgets that is C++. It will allow you to write a single code for the window initialization of your application that compiles on each platform.
wxWidgets also have a python binding if you decide to go for python in which case you would also need PyOpenGL.
For casual gaming I would recommend Flash
精彩评论