Wednesday, 30 January 2013


Yeah. Surrounded is going to be scriptable. Primarily this will enable mods to alter the way weapons are used and the way levels and actors are generated, but I also intend to make an event system and allow scripts to stick dialogue/narration/info on the screen.

Weapons in particular are going to be very flexible. They could require a pattern match for the user, target, both (classic Encircled), or neither (classic RL), and each square of the pattern could match any subset of up to 16 terrain types. Patterns could be transformed according to any subgroup of the octagonal symmetry group. Weapon range could be any integer from 1 upwards (but to make it fair on the player, mods should restrict maximum range to fit the number of tiles on the screen). Weapons could hit any number of targets from 1 upwards. Weapon damage could be any number (and damage could even be inflicted dynamically by the script, enabling Hydra Slayer-like mechanics). Actors could have movement types that restrict them to a particular subset of terrain types (Like the red-blue things in HyperRogue II/III or the ghosts in Angband). Ranged weapons could require line of sight that only passes specific terrain types (so that a bullet, but not an arrow, can be shot over lava), and the user and target locations could be included or excluded in this line-of-sight (so that a ghost hiding inside a wall can or cannot attack or be attacked). Actors could potentially inherit their movement type from their weapon's line of sight, or vice versa. This could lead to lock-and-key type puzzles. Some weapons could also work by counting the number of tiles matching subsets of terrain. Sprite sheets of course would be redefinable.

Depending on how crazy I'm feeling, I might allow pattern matching to include tiles at arbitrary offsets from the pattern's centre. That would be rather difficult to represent in the UI, though.

Using all of these features in the same mod would likely lead to confusion, imbalance, and unplayability, but I'll assume that modders (and I) have enough restraint to use subsets of the available features that lead to entertaining and comprehensible games*. The point is that not having to recompile every time I change game content will allow me to balance the game much faster. If it's done in time, I could even make a mod in for 7DRL this year (which I expect is going to be a busy time in real life).

* But I promise to include one mod that uses every mechanic in the game. It might be difficult to make it winnable...

Monday, 21 January 2013

Smooth Animations

Yep, I wasted few hours making actors in Surrounded slide from one tile to the next. Doesn't feel like a waste, though - the effect's quite pretty.

The moving animation is independent of the engine, so the user can interrupt it at any point with their next command. The actor sprite then jumps to the next position and resumes movement. In order to make this smoother, the game remembers the length of time the user gave the last few animations. It averages these to predict the most appropriate speed for the next animation. Thus, if the user types input at a more-or-less constant rate, the sliding will mostly be continuous, without pauses or jumps. Artefacts may be noticeable at the first of a sequence of fast moves, or after a series of fast moves.

Also, actors fade in when they first get put on the map.

Wednesday, 16 January 2013

Doing it properly

The trouble with spaghetti code is that it's too rigid to comfortably fit in a different box to its original. Surrounded was mostly working nicely, but there were missing pieces of user interface (mostly monster health), nasty bugs associated with victory/defeat, and a general inability to add all the cool new features I wanted to.

So, refactoring. I started that by attempting to write a basic GUI menu system in raw SFML. Bad idea. After deciding to use a library, and eliminating GWEN, libRocket, SFGUI, and a few others, I settled on CEGUI. Bad idea.

CEGUI was the only usable thing left though, so I struggled through it and managed to get a menu system with a decent look and feel running. The CEGUI standard skin, Taharez, is very complete and looks good, except for the default cursor which is insupportable. Luckily I managed to find GlossySerpent, which looks like a homage to Warcraft III and has an acceptable cursor. Not ideal considering the more sci-fi-like angle I took when figuring out a setting for the game, but it'll do for now.

Yes, Surrounded has a setting and a plot now. It was quite difficult to figure out a world where such Schoenbergian game mechanics would make sense, but somehow it only took a day to figure out.

Anyway, I can now define menus quite nicely in XML using CEGUI's GridLayoutContainers to avoid specifying exact locations (but calculating the margins takes some effort). That means I can actually start focussing on transferring in the game code - the 96% of the work which will probably take 20% of the effort.

Yes, I've been drinking the optimist kool-aid.