Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 else 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?

like image 858
Giovanni Funchal Avatar asked Mar 08 '10 13:03

Giovanni Funchal


People also ask

What is meant by cross-compilation?

Cross-compilation is the act of compiling code for one computer system (often known as the target) on a different system, called the host. It's a very useful technique, for instance when the target system is too small to host the compiler and all relevant files.

What is cross compiler with example?

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on an Android smartphone is a cross compiler.

Is GCC a cross compiler?

It is used to build programs for other system/machine like AVR/ARM. TurboC or GCC is native Compiler. Keil is a cross compiler.


1 Answers

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 bliting 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).

like image 126
Daniel G Avatar answered Sep 29 '22 08:09

Daniel G