Author: | George F. Rice |
---|---|
Contact: | behexed@drgeorge.org |
Date: | 2007-01-01 |
Web site: | http://behexed.sourceforge.net/ |
Copyright: | This document is released under the Gnu Free Documentation License |
Behexed is a single-player strategy / light arcade game playable on most platforms, including small portable environments that support the PyGame runtime libraries. Similar conceptually to Bejewelled™, Behexed is based on a hexagonal rather than square board layout, offering additional sequencing opportunities. A unique multi-swap move option allows agile players to set up more complex scoring sequences than similar games.
Behexed offers multiple themes to customize your gaming experience. The comprehensive manual includes instructions for creating and sharing your own themes.
Run the file named "Behexed.py". On most computers, this means double-clicking that filename. You can create a shortcut in your Start / Applications / K menu for quicker access.
The upper pane of the screen provides a short overview of the game. The Readme file can be launched in a browser window by clicking the blue word "Readme".
The lower pane is divided into 4 sections. The right side of the pane shows up to the 8 highest scores achieved - the date the game was played and the corresponding score. This table is stored in a file in the program folder named highscores.txt. To clear the high score table, simply delete this file.
The upper left section of the lower pane lists three options.
The bottom of the lower pane contains copyright information. This information may not be changed if the intro screen is modified. The words "click here" are active links to the GNU license agreement, which will open in a separate browser window if clicked.
The words "Play Game" in the lower left of the lower pane is an active link that launches the Game Screen using the selected options. Just below, the words "Resume Game" permit continuing a previously saved game (if no game has been saved, the Intro Screen will remain visible).
The hexagonal game grid contains 8 columns of 8 icons per column. An icon can be selected by clicking it; this is indicated by the icon slowly flashing. A selected icon can be exchanged with an adjacent icon (above, upper right, lower right, below, lower left, or upper left) if and only if the exchange will create a scoring sequence, by clicking the adjacent icon.
A scoring sequence is three or more icons in a straight line - vertically, slanting down to the right, or slanting down to the left. When a scoring sequence is formed, all of the icons comprising the scoring sequence explode and vanish, allowing icons above them to fall into their positions on the grid.
The points awarded for the scoring sequence depends on the number of icons in the sequence, and whether the timer is active. The following table shows the points awarded for each sequence.
Icons | Timer Off | Timer On |
---|---|---|
3 | 10 | 15 |
4 | 30 | 45 |
5 | 100 | 150 |
6 | 300 | 450 |
7 | 1000 | 1500 |
8 | 3000 | 4500 |
Centered above the game grid is the scoreboard, which tracks the score earned for each scoring sequence formed.
To the right of the scoreboard is the Hint button. Clicking Hint will select the icon that, if switched with the correct adjacent icon, will result in the most points. If no valid switch is available, the game is over (this is the <em>only</em> way to end a game and submit your score for consideration on the High Score table). Each hint costs a few points, starting with 10 for the first hint and approaching 40 after several hints have been requested. Immediately following a Hint, the button changes to End Game, which can be used to record your high score and exit to the Intro Screen.
To the far left of the scoreboard is the New button, which will return to the Intro Screen, which will return to the Intro screen without recording high scores.
The the near left of the scoreboard is the Save button, which writes the current game to local mass storage (in particular, to a file named "savegame.txt"). The game can be resumed from the Intro Screen using any Theme and set of Options by selecting Resume Game. Only one game can be saved at a time.
You may notice that score is not awarded until after all icons come to rest. After creating a scoring sequence, while icons are falling due to the explosions you created, the gameboard remains active. If you make another swap before the falling icons come to rest, the icons will return to their pre-explosion positions, your swap will be executed (if it is valid - that is, it creates at least one additional scoring sequence of 3 or more icons), and the board re-scored.
Thus, if you have two matching icons in a row, and three identical icons that could be swapped into a scoring sequence, you can (if fast enough) swap each additional icon into the sequence (if swapped in the correct order, so that each swap extends the sequence by at least one). Once you have all five in a row, simply allow the falling icons to settle to receive your (much higher) score.
Note that to select a falling icon, you must click where the icon started, not where it is during its fall. This takes a bit of practice. Try to sequence your swaps in a move so that you are selecting stationary icons as much as possible.
If you create a vertical sequence adjacent to the top, no icons will fall, ending the move. When trying to create a multi-swap move, try to swap the top icon into position last. If that's not possible, create another sequence first, and use the icon fall time for that sequence to give you time for multiple swaps on your primary sequence.
A vertical sequence causes icons to fall further (that is, longer) than a diagonal sequence, making it easier to add additional swaps to the move. If you're trying to create a long diagonal move, it will be easier if you first create a separate vertical sequence below the top row, then use the extra falling time from that sequence to set up your long, high-scoring diagonal sequence.
Given several sources of an icon to create a sequence, pay attention to the non-scoring icons. Select the swap that moves non-scoring icons closer to matches, creating additional scoring opportunities.
Finally, show preference for creating avaiable sequences near the top of the board. Scoring sequences low on the board will often disrupt opportunities above them, so grab the upper points while available. Once opportunities on the upper half of the board are exhausted, creating a sequence low on the board may open additional possibilities above.
Behexed considers every subfolder of the game folder to be a theme. The name of the subfolder is used as the theme name.
A theme consists of the following files. Image files identified as "transparent" will take the color of the upper left pixel as the transparent color reference. Files labeled as "buttons" are nominally 64x32 pixels, but may be smaller if desired.
1. behexed.gif - This approximately 375x480 pixel image is the background for the gameboard. Make certain your theme's board labels the New, Score and Hint buttons appropriately.
2. new.gif - This transparent button will be used as the New button on the gameboard.
3. save.gif and saved.gif - These transparent buttons will be used for New on the Game screen.
4. hint.gif, endgame.gif, and gameover.gif - These transparent buttons will be used for Hint on the Game screen.
5. iconN[A].gif - Twenty transparent 32x32 pixel images represent the ten icons used in Behexed. The image files are numbered (that is, N =) 0 through 9. The normal image has no suffix; the alternate image uses the suffix "A". The normal image represents the icon in normal play. When the icon is selected, the normal image is alternated with the alternate image - so, icon0.gif is alternated with icon0A.gif when selected. Icons needn't actually flash, of course - any two-state animation can be created.
One good rule of thumb is to use a color-averaging filter on the normal image to create the alternate image. Another option is to off-set the alternate image by two pixels to the lower right, causing the icon to oscillate when selected.
6. explosion.gif - this 48x48 pixel transparent image is flashed briefly over an icon that is being removed.
Distributing new themes is most easily done using the popular ZIP format. Include the subfolder name as part of the ZIP file, allowing a user to simply unzip the file in the game folder to install the theme.
Behexed is written in Python with the PyGame library, and should run with minimal changes on any platform that supports this environment.
A Boolean constant in Behexed_pygame.py and Behexed_intro.py named VERTICAL determines board orientation. This enables the board to be rotated clock-wise for use on small devices with a screen that is wider than tall.
Music and sound effects need to be added.
VERTICAL really should be a command-line or config-file option.
Although the game runs (in non-vertical mode) on a Nokia 770, Hildonization is needed to be a true Maemo app. In particular, Behexed does not recognize a sleep event, and thus keeps happily animating icons until the battery (rather quickly) dies. Be careful. You have been warned.
The game should install with a professional installation wizard on Windows, a .deb package on Debian-family Linux, and an RPM package on Red Hat-family Linux. Solaris and Mac packages would be nice, too. It would be great if Python made this easier (hint, hint).
Two-state animation for selected icons is a bit constricting. Instead, check for additional icons (e.g., icon0B.gif, icon0C.gif, ...), and cycle them at (say) 6 frames per second. This would permit (for example) icons that spin, dance, or scroll amusing messages when selected.
Adding a player's initials with his high score would be a nice feature.
A few other scoring combinations have been suggested, most notably a circle (i.e., six identical icons surrounding a different icon).
A more general implementation would permit themes to change the size of the game board, which means including a config file for critical parameters such as where the icons and buttons should be placed on the gameboard. A really general implemenation would also permit changing the size of the board from 8x8 to NxN (which also means changing the number of icons in the game, since the balance of board size to number of icons is critical to a playable game). This is left as an exercise for the student.
If you enjoy programming games in Python, the Hex and Map classes may prove useful. They were intentionally designed to be reused in creating hex-oriented games such as fantasy combat and classic wargames. Also of potential reuse is the HighScore class, which manages a variable-length date-stamped high score table.
Hex.py represents a single hex, with links to its adjacent neighbors. Direction is an integer between 0 ("north") and 5 ("northwest"), but any integer is acceptable - for example, 7 is the same as 1 ("northeast"), and -3 is the same as 3 ("south").
Hex provides a suite of methods (Next, NextLeft, NextBack) to return adjacent hexes, and the adjHex method to return the direction to an adjacent hex. Hex also supports the concept of a "stack", based on stacks of cardboard counters in old hex-based war games, with methods addStack, delStack, and stack.
Map.py models a 2-dimensional array of Hex objects, or at least objects that are duck-type compatible with Hex objects (such as a subclass). Methods adjHex and adjDirection determine the direction to an adjacent hex by object or coordinates.
The setMark method creates a stack on each hex using either a static value or a unique value per hex returned by a lambda-compatible function.
The strStack method is a very flexible method for converting a map into a text representation, with conditional hiding of hex contents based on other stacks and a lambda-compatible call-back filter mechanism.
HighScore.py models a persistent sorted table of date-stamped high scores. The table is associated with a filesystem path and filename, created on first use, and rewritten on each high score update.
Behexed is licensed under the Gnu General Public License. You may freely share this program with family and friends, and you may also use part or all of the source code in your own programs as described in the GPL.