Sunday, January 29, 2012

Game data in a zip file

For our platform game, we wanted to minimize the number of files needed to play the game. The best would be to distribute just a single exe file, but getting all SDL libraries statically linked seems to be a challenge. This post is about the game data files (sprites, sounds and level data), and how to make the game access them directly from within a zip file.

Our current approach uses zziplib and SDL RWops. Zziplib makes it easy for the program to access files inside a zip archive. As a bonus, the library looks for the file outside the archive first, so one can keep the game data as separate, regular files while programming and testing. For distributing the game, one simply packs the data files in a zip archive, the program will still find them. SDL RWops is a mechanism for passing data to SDL functions, when loading images or sound clips. The data may be stored in memory, in a file or in some other way.

The zziplib homepage gives an example program for getting a RWops structure from zziplib. I made a few modifications to it, which I want to share here. The code is not yet pretty, it is at the works-for-me stage.  In particular, the mode argument is handled sloppily. The original example file was released under the zlib license, so the same applies for my modified versions.
SDL_rwops_zzip.c  SDL_rwops_zzip.h

First, mingw does not like the names _zzip_read() and _zzip_write(), it reports a name conflict. I guess this is a mingw problem, but it is easy to get around by changing the names, which are used only locally in this file.
SDL_rwops_zzip.c:23:12: error: conflicting types for 'read'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/io.h:452:37: note: previous declaration of 'read' was here

Second, zziplib supports obfuscating the zip archive, which makes it slightly harder to see the files inside it. It would be nice to use this feature together with the RWops. In the c file below, I have simply combined the obfuscation example from the zzlib site with the RWops functionality. A nice feature: obfuscation is applied only on files found in a file with the extension .dat, unpacked files and files in a .zip archive are assumed not to be obfuscated. I also added the function openZzipFile(), which opens a file with the same obfuscation mechanism but does not turn it into a RWops structure.

Monday, January 23, 2012


Salmiak-shaped candies of, well, salmiak. They make nice mosaic blocks as well.  Unfortunately the angles are slightly off: I thought three fat or six thin corners would fit together, that would have given more pattern options.

Saturday, January 21, 2012

Shiny and New

Ordered some new polymer clay tools from a German online polymer store - a Kemper needle tool, a ripple blade, and a set of tiny 5 mm (5/16 in) Kemper shape cutters.

Wednesday, January 18, 2012

Bubbles II

bubble grid

A raft of bubbles observed one day while doing the dishes. For some reason, many bubbles of equal size appeared. Here they have arranged themselves in a crystal. A few impurities (bubbles with a different size) cause crystal defects.

Bubbles have actually been used to study and visualize the physics of crystals. Here some videos, and an early article about the technique by Bragg.

Saturday, January 14, 2012

Platform game, release 0.02

Now it is time for a new version of the platform game! This time it is possible to win the game and also to die, so now there is a clear goal for you. As before, comments and bug reports are welcome.

The game for Windows. Download the zip file and extract the folder. Double-click the file game.exe to run the game.

The Game for Linux 32 bit, and The Game for Linux 64 bit. Download one of the zip files above, according to your operating system (typically 32 bits for older computers). Extract the folder game002, and run the file game. You will need to have the libraries listed in the previous post installed for the game to work.

The same small print as before: The game, program and artwork are copyright 2012 by Johanna and Fredrik.

Wednesday, January 11, 2012

Swirly Flower Cane

A new polymer clay project - a square flower cane.

Building the cane. The swirls and the stem are a mix of Fimo browns - 76 Cognac, 7 Caramel, and 75 Chocolate. The background is one fifth 39 Peppermint and four fifths 0 White. Petals are layers of 26 Cherry Red and 22 Raspberry.

The cane is wrapped in an extra layer of background, before reducing, to protect the pattern. On the right, the cane reduced to a size of a few square centimeters. I later made beads and a bracelet from this cane.

Monday, January 9, 2012

Antivirus Anger

We planned to release a new version of the platform game last weekend, but unforeseen technical problems appeared. Compiling the game for Windows turned out to be difficult. We program the game in c, using Linux. Thanks to the SDL library and MinGW, a Windows port of the GNU c compiler, the game should be easily portable to Windows as well.

The first problem was F-secure's antivirus program. When I compiled our game, it immediately recognized the game's executable file as a virus and removed it (for our protection). It turned out that not just our game got treated this way, but even the smallest possible c-program with an empty main function was detected as malware as soon as I compiled it. I am using the current MinGW, with gcc 4.6.2.

My various test programs were classed as Gen:Variant.Graftor.11442, Gen:Variant.Graftor.11230, Gen:Variant.Graftor.10418, Trojan.Generic.KDV.492012, Gen:Variant.Kazy.50358. Of course we could turn off the stupid antivirus scanner, but then the problem would probably just move to whoever tries our game and has the same antivirus system installed. Switching to an older gcc (version 3.4.5 which I had lying around) made the problem go away. Also, the most recent version of the game seems to avoid the virus scanner, for no apparent reason.

EDIT 21.1.2012
I was going to report the problem today on the MinGW-users mailing list, only to discover that an empty program is no longer classed as a virus. Maybe f-secure updated their scanning system?
Newer Older Home
Related Posts Plugin for WordPress, Blogger...