BEWorld source code

Icon


Contents:

1   Overview
2   Screenshots
3   History and licenses
4   Related links
5   Browse the code
6   Questions and comments
7   Requirements
8   Installation
9   Notes for developers



1. Overview.

BEWorld is a simple Linux game and a starting point for coders who are interested in developing similar games; Tcl coders, in particular, as this version is written in pure Tcl plus the Brick Engine.

The game consists of a self-contained Tcl script. Sound effects, music, and sprites are all embedded in the script. There's no need to install any external bits and pieces except for a Brick Tcl 5.4 interpreter and the packages that it uses (primarily SDL, Tcl, and XOrg).

Note: The Brick Tcl 5.4 interpreter is included in BEWorld's source bundle and installation instructions are provided on this page.

This is a fork of an older (apparently unnamed) demo program by the lead developer for the Brick Engine. The flavor is similar to that of a real-time Nethack; there are several connected rectangular worlds and the goal is to travel through the various worlds and make it to the end. However, the current version is more limited than Nethack. It should be thought of as a proof of concept.

That said, the game features sprite code that's relatively easy to work with, both random and invariant levels, a map generator that should work in other games, support for embedded music and sound effects, the start of an object-oriented component framework, and other features that may be useful.

The version of BEWorld provided here is intended for developers. Regular users are welcome to give it a try, but note that installation requires a “build” procedure. For more information, see the following sections.




2. Screenshots.


image

Typical BEWorld scene


image

Denizens of Caspak greet the hero




3. History and licenses.

Steve H., the creator of the Brick Engine, wrote an apparently unnamed Brick Engine demo in the 2000s. It used an old version of the Brick API (one that predated Brick 5.2).

BEWorld started out as a port of the demo to the Brick 5.2 API. Subsequently, the code was restructured and new features were added (with Steve's advice and assistance). Eventually, it was ported to the Brick 5.4 API. Brick 5.4 is now required, though older APIs are partially supported.

Brick Engine 5.4 and the associated Tcl bindings are released under the MIT/X license.

BEWorld 110923 is released under a Creative Commons license; specifically, Creative Commons Attribution NonCommercial ShareAlike 3.0. This includes the music, but note for attribution purposes that the code and the music were created by different people. For more information, see the source code.

Additionally, note that some of the Tcl algorithms are based on public posts by various Tcl developers. Credits are included in the source code.




4. Related links.

Here's some links related to BEWorld and Brick Engine. Note: These links were valid as of September 2011 but they may have broken since then.

BEWorld Freshmeat page:

http://freshmeat.net/projects/beworld/

Brick Engine home page:

http://rs.tc/br/

Brick Engine Fossil repository (library):

http://rs.tc/cgi-bin/fossil.brick-engine

Brick Engine Fossil repository (bindings):

http://rs.tc/cgi-bin/fossil.brick-engine-bindings

Brick Engine TCL API Reference:

http://rs.tc/br/doku.php/quick_reference_tcl

Note for engineers: BEWorld 110923 uses the Brick API 5.4 as it stood circa September 23, 2011. The API described on the page linked above may be older or newer. For more information about API issues, see the BEWorld source bundle (which you can get at the following link).

BEWorld source bundle:

beworld-bundle-110923.zip

The BEWorld source bundle is based on Fossil checkouts of Brick Engine library and bindings source trees. If you'd like a copy of the script that was used to do the checkouts, it's at the following link:

brick-fossil-specific.txt

The preceding script checks out exactly the library and bindings revisions that were used to make the BEWorld source bundle. If you'd like an alternate script that checks out current source trees (as opposed to specific revisions), use this link instead:

brick-fossil-current.txt




5. Browse the code.

If you'd like to browse the current BEWorld source code, click here.

Note: Most of the binary data that's embedded in the source code has been removed to make the code easier to browse. To obtain a complete version, download the BEWorld source bundle.




6. Questions and comments.

Questions and comments may be sent to:  oldcoder@yahoo.com

If you're interested in other tools and components, the developer's home page is located at:

http://oldcoder.org/




7. Requirements.

BEWorld itself doesn't need to be built; as noted previously, it's a self-contained Tcl script. However, if you'd like to play the game, you'll need to build the Brick Engine 5.4 library and the associated brick-tcl interpreter. If you're interested, proceed as described in this section and the next one.

Start with a Linux distro that includes cmake, gcc, and development packages for XOrg, SDL, Tcl, jpeg, and libpng.

Note: “development packages” means packages that provide header files and libraries. The exact names of these packages will vary from distro to distro.

SDL should include the core SDL library (release 1.2.10), SDL graphics (2.0.22), SDL image support (1.2.10), and the SDL mixer (1.2.11). Other releases may (or may not) work.

For Tcl, any of the 8.5.X releases should work. 8.4.X isn't supported.

For gcc, release 4.4.3 is recommended, but 3.4.6 and 4.2.4 may work. gcc 4.5.X and 4.6.X are terra incognita; if they work, or don't, send email describing what happens.

OpenGL isn't required. BEWorld should work fine whether or not you have OpenGL libraries or related features such as DRI, DRM, accelerated graphics, or direct rendering.




8. Installation.

The following instructions are intended for Linux developers. These instructions assume that people are familiar with Linux “build” procedures in general.

(a) Optional: Log-in as root.

If you're logged in as root, the game will install to a directory tree named /opt/beworld and anybody will be able to play it. If you're logged in as an ordinary user, the private (or semi-private) directory tree $HOME/beworld will be used instead.

(c) Verify that the development packages discussed previously are installed.

(d) Go to /var/tmp and unpack the BEWorld source bundle there. Other directories may be used as well (for example, $HOME/tmp).

(e) Step (d) should create a subdirectory named beworld-bundle-110923. Go into that subdirectory.

(f) Execute this command:  sh ./buildme.sh

The preceding command should build Brick Engine and brick-tcl. Additionally, it should install a copy of BEWorld. If copies of Brick Engine and brick-tcl are already installed in system trees such as /usr or /usr/local, those copies won't be overwritten or affected.

If the buildme.sh command is successful, it'll tell you the location of a script named beworld. To play the game, just run the script. There's no need to set PATH, LD_LIBRARY_PATH, etc.

(g) At this point, you can delete the subdirectory mentioned in step (e). It's no longer needed.

Note: If you play the game, you should hear music as well as sound effects. If sound normally works for you, and either feature is missing, feel free to report this to the email address given previously.

To uninstall the game, just delete the directory tree /opt/beworld or $HOME/beworld.




9. Notes for developers.

BEWorld developer documentation is located in the source code. Here's a few notes for developers who may be interested.

9.1. This isn't an object-oriented program in the standard sense, but it does use objects and classes in a manner of speaking.

An object class is something for which two routines new_NAME and run_NAME exist (NAME being the name of the class). new_NAME creates an instance of the class. run_NAME is called subsequently (and repeatedly) for each instance to initiate and/or direct actions by the instance.

An object-class parameter is any program parameter that's tied to a particular object class. Most object-class parameters may be set either as global defaults or on a per-world basis.

As an example, most mobile objects honor object-class parameters named divmin and divmax. These two parameters set minimum and maximum “speed divisors”, respectively.

Smaller speed divisors result in faster sprites. Larger speed divisors reduce sprite speed. Values of about 3 to 5 produce average speeds. Presently, the minimum value supported is 1. This value produces the maximum speed.

9.2. The playing field consists of a set of Nethack-style rectangular worlds (one world at a time).

Worlds are connected by “forward” and “reverse” portals. These are similar to Nethack's “down” and “up” stairs, respectively, and games derived from BEWorld may use them in the same way. However, this interpretation is an oversimplification; “forward” and/or “reverse” portals may lead to either “higher” or “lower” levels, or to different worlds located on the same level.

Each “forward” portal is associated with a destination world name and a “reverse” portal located in the specified world.

Each “reverse” portal is associated with a destination world name and a “forward” portal located in the specified world.

When a world is created (by make_world), a sprite is added for each “forward” portal that it contains. No “reverse” portals are created, initially.

When the player enters a “forward” portal, the associated destination world is created (unless it already exists) and he/she is transported to the world in question. The transport process adds a “reverse” portal to the destination world that is connected to the “forward” portal used, unless this was done previously (as part of an earlier transport).

When the player arrives at a destination portal, the portal is locked until he/she steps off of it. This prevents infinite transport loops.

9.3. BEWorld embeds all of its data (music, sound effects, scroll text, etc.). Much of the data is compressed. Two types of compression are supported. One type is lossless; this is used for the game music (which is an embedded MOD file) and for other data that must be preserved exactly, such as scroll text. Another type is lossy; this is used for sound effects.

The lossless compression algorithm is based on LZ77. The lossy compression algorithm is based on a data format named bxdiv that I designed with simplicity in mind. For details and instructions, see the source code.




Hosting provided by Zymic.

For acknowledgments related to CSS and other code used, click here.

Linked or embedded works (software, books, articles, etc.) are presented under their own licenses.

Other unique content on this page, excluding screenshots, is distributed under the following license: C.C. Attribution NonCommercial ShareAlike 3.0. In some cases, screenshots are distributed under the same license. In other cases, the associated program's license applies.

image Valid XHTML 1.0