Blitz2D Newbies: Open-Game Design
by MadProf

Recently Krylar posted an article about encryption of data in a game. This means that you can stop crackers from making your game look different, or changing stuff you'd rather they didn't.

Personally I prefer to keep games "open". This means that anyone can release mod-packs, levels, extra-animations, etc. which:

  1. stops crackers, nothing to crack ;)
  2. lets your game have an infinate (more or less) number of developers, who can help you make it better.
  3. lets you get a "community" for your game, so people can release mod-packs & levels, but it will just be an extension of your game, not "hacks".

Civilization II, (IMHO a brilliant game, I still play it) did this. The game "rules" were as simple text files, and had comments to help people make modpacks. The graphics were simple .gifs, and had info on making modpacks. The game lasted *ages*. It was released (I think) in '95, and still lots of people play it, make mods for it, and release the mods on the net.

For large games you will often need to write a level-editor. I've found my editors are horrible "press 's' to save, right-click to delete an object, left-click to create an object, 1-to-9 to set object to create" sort of thing. Now this isn't a bad thing, in its way, as it allows you to have a very simple level editor very quickly so you can get on with coding.

Release the level-editor with the game, or even release the source-code of the editor, and so allow someone else make a better one =). Its a good idea to comment open-source code *very* fully, as you are not the only person who will be looking at the source-code.   Not only will you drive people off who might have helped if they could understand any nasty bits of un-commented code, but also its a lot easier to comment at the begining than later.  Also write some documentation for it, writing simple text-file docs are not hard, and they *really* make it a lot easier to use.

Use the standard .bmp (or similar) for the animations, as others can edit these easily, in GIMP, photoshop, or even paint! again, write some documentation on how the anims work, and perhaps include some example files.

If you can be bothered, another nice thing is to write some option-loading from a text file. With Blitzbasic this is not difficult, and its not *that* hard with other languages either. Normally a file will look a little like this:

; Rules.txt (C)Copyright 2001 MadProf's Workshop
; ----------------
; Edit this file AT YOUR OWN RISK. You can really get
; the game screwed up by putting in stupid values.
; ----------------
;
; Gravity Ammount:
; how much faster objects will fall every frame (eg:
; 2 = 0,2,4,6,8,10,12...etc.
; normally this value is 2.

grav 2

; Jump-ammount:
; how much "anti-gravity" the main char. will get when he jumps.
; each frame this value will drop by the grav value.
; normally about 20.

jump 20

;etc...

Now this is a very simple options-type file for a platform-game, which is fairly obvious. its very easy to edit, and well commented. you can have rules in it like the format, comments start with ";", blank lines are allowed, and each rule *must* have no spaces, and be 4 chars long. Very easy to use this setup, and very easy to code:

; I'm using BB for coding, as its simple.
Include "val.bb"
Global grav% ; the gravity value.
Global jump% ; the jump ammount.

a = ReadFile ("rules.txt")
While Eof(a)<>1
  ; read the line...
  gotline$ = Trim(ReadLine( a ))
  ; if the line is not a blank-line, or a comment:
  If gotline$ <> "" And Left(gotline$,1) <> ";"
    ;now check for the wanted values.
    Select Lower(Left(gotline$,4))
    Case "grav"
      grav% = val(Trim(Mid(gotline$,4)))
    Case "jump"
      jump% = val(Trim(Mid(gotline$,4)))
    End Select
  End If
Wend
CloseFile a
Print grav%
Print jump%

As you can see I'm including  "val.bb". As BlitzBasic doesnt (yet) have its own string-to-integer converting function, I wrote my own (thanks Krylar for ASC idea!). The function works just how you think it ought to, and is included in val.bb. To download all of the source for this stuff: Click Here. Once BB has its own version of this (IMHO very vital) function, that bit wont be needed.

Now your game is mod-packable! If you're feeling really keen you can even write some code that loads a modpack from a modpack-directory, to make it even simpler for people.  Write some more documentation, and say you'll link from the "offical site" you've made to any modpacks they make.

This method gives an alternative to encrypting your game-data, and may help your game to stay popular for a longer time (possibly!).

-MadProf


For a printable copy of this article, please click HERE.


This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.