Tuesday 11 July 2017

Project 2: "Only Fools and Corpses"


Only Fools and Corpses

An on-going, WIP, personal project (sadly, another project I haven't had time to work on lately), OF&C is a strategy/survival/simulation game, in which the player creates a zombie virus and infects a small town.


The goal is to design a plague that will destroy the town's inhabitants with the plague. The player gets 25 points to spend on the various attributes (there are tooltips to explain each option).

Then, the player gets to travel the town and choose an infection point. Once selected, they launch the capsule and set off the infection (and a panic).

Whilst infected, citizens can infect eachother, and may head to the hospital to get cured (the likelihood of these events is based on choices the player makes during design). Once the victims die and become zombies, they begin attacking the town (its citizens and buildings). Certain buildings provide bonuses, and certain citizens will defend themselves (there are also police who will attack the zombies - and the player if they see them throw the capsule).

The big twist of this game, however, is that the zombies can, and will, attack the player given the chance. The player needs to be clever and quick to successfully destroy the town, and progress to the next level.

As with all my projects featured here, I was the only programmer for this game. In this case, I was responsible for level design and creative direction as well. The game has a pixelated, quasi-fifties style, with black & white dialogue cards, washed-out colours, and grainy filters.

One of the biggest features is the AI, which is fairly complex - the police coordinate with eachother, but lose that advantage if the police station is destroyed - they also have panic levels, which determines how brutal their behaviour will be. The citizens have a range of panic reactions to select from (which is affected by various factors - such as base 'bravery', damage taken, number of enemies, etc). The zombies are fairly simple - they can flock together, but also react to damage taken, and get taunted by certain things as well.

There are some other neat, little features as well - such as the procedural citizen generation (skin tone, hair style, colour, face and name are all procedural). Citizens are also grouped by surname - they share homes and have more severe reactions when family members are hurt.



This project took about two months of work to get to its current state (which, as mentioned, is not quite complete).

Here is a short gameplay demo (as you can see, it is very much a WIP, but it has some interesting potential, and programming the AI was a great exercise).


I will be uploading a copy of the game so far, so you can sample it for yourselves.

Monday 10 July 2017

Side Project: Random Shaders


Side Project: Random Shaders


Shaders can be very rewarding, I think mostly because of their inherent visuality; the results are instantly visible (or not, if something has gone wrong). It can also be highly experimental - the level of documentation varies wildly, requiring a lot of hands-on learning and exploration (which can be fun too).

As part of my experimentation with shader programming, I created some utility / random shaders. Some were made to solve particular problems, others were simply experiments / exercises to develop my knowledge or test theories I had on possible shaders. Here are some of my favourites (in no particular order).

1) Dynamic Text Recolouring.

I found I had a problem with text readability; if the font's colour didn't contrast enough with the background, the text was difficult or even impossible to read.
To fix this, I made a simple shader to be applied to the text which uses a grab pass to perform a per-pixel contrast check, and then swap the text based on the background colour. This means that text is (usually) readable, regardless of the background colour.
There are some cases (contrast-noisy textures, as with bright, but normal-mapped textures), which cause some issues with this method - the text can become noisy as well. To fix this problem, I am hoping to create a compute shader version in the future - which will swap the whole text if more than 50% of its pixels requires the contrast boost.



2) Color 'Rotation'

After theorising the results, I decided to try and create a shader which would rotate the color vector (rgb) of a light source by a specifiied amount. The result is a texture which receives a color-wheel from light sources. The frequency of the colors can be adjusted for some very strange effects!


Here is the same light, but with the frequency massively increased:



3) "Grey Light"

After playing around with light sources inside material shaders, I came up with an interesting project idea - a material which would fade to greyscale based on its illumination by lightsources. The end goal being a shader which allows the user to specify a lightsource to receive this effect from - and which otherwise behaves normally.



4) Additive Alpha Removal

When creating a range overlay effect for a strategy game, I encountered a lot of problems with additive alpha blending on transparent objects. This meant that the range area markers would overlap horribly. to fix this, I created a simple shader which uses the stencil buffer to limit the alpha of all pixels to the same amount - the results have been very useful.


5) Targeted Dynamic Colour Replacement

Another exercise, this shader has actually proven useful to several artist friends of mine (or so they tell me - maybe they're just being nice). This material shader will dynamically replace all instances of a specified colour with another specified colour. The accuracy of the colour comparison can be specified for artifact removal / experimentation.


The inspector is fairly self-explanatory, but just in case, ReplaceThis is the colour to be swapped out, and Replacement is the color to swap it to. The above settings provide this output:-



Well, that's all the shaders I wanted to show off for now. Hopefully you found some of them interesting!

Project 1: Simple City Generator


Procedural, Grid-Based, City Generator


As an exercise, I decided to create a procedural city generator. It is quite rudimentary, but has some interesting elements that are worth mentioning.

The Unity-built generator works by populating an area with pre-defined (and measured) prefabs (such as specific road segments).

The first stage creates a central junction, which is then extended with randomly selected pieces - to create a random distribution of junction points along a primary 'X'.


After this has been created, the algorithm finds the intersections of all junctions and fills the road layout in accordingly - creating junctions and straight-pieces as necessary.

As you can see, at this point the generator has created a fairly effective (if a bit robotic) road layout. Naturally this creates rectangular spaces between the roads, so by using a box-packing algorithm, the spaces can be neatly populated with building prefabs.

However, in order to make the cityscape a little more interesting, the algorithm random spawns a number of "district nodes" (a point in space with a specific enumerator type attached to it). Each rectangle measures its distances to these nodes and selects from a different pool of building prefabs, based on the type of the node. In short, the city generator creates districts which have a consistent feel - allowing for the creation of residential, industrial, political or other themed sections of the city.


Here you can see the result - clustered buildings of different types forming different districts within the city. (Please excuse the white-box assets - I am not a 3D modeller and have to make do with what I can find / convince friends to make in their free time).



As a final touch, I added invisible, weighted, pathing geometry to the road segments / crossings, and added Oculus Rift support so that the player can explore the city in first person, and meet its denizens (who are designed only to spawn / navigate around the player).


Project 0: Flatliners


Flatliners was the title of my final year project at Salford University. It is a first person speed-running game, based on CSS surf maps and other community-spawned games.

Here is one of the promo gameplay trailers the team made. (The music may be quite loud!)

I was the sole programmer for this project, which was made with Unity in about 4 months.

The game itself included a tutorial and a single level to showcase the core mechanics.



Some of the other features which were interesting to develop were:

1) the Ghost/Replay system which not only recorded a playthrough, but also allowed the player to compete against their own records. It also featured some rudimentary data visualisation for saved playthroughs.

2) movement itself was quite complex on this game as the exact details and contingencies weren't finalised in the design until late on in the development cycle. It had a strange mix of inertia, fixed (and jump-based) acceleration, and very high speeds.

3) the projectile system was pretty challenging; the game was dealing with very high speeds most of the time, so there were a lot of issues with spawning bullets and detecting collisions. I solved these by performing ray-based distance checks and only spawning the projectile when the distance was sufficiently far - otherwise, it assumed a hit and spawned the explosion of the projectile immediately. (This helped improve the control fidelity of the Rocket Jumps).

4) to make the game scalable, I added a modular level system - unity asset bundles were added to a specific directory, along with a picture and a manifest, which provided in-game information about the new levels.

There were many other rewarding aspects, as well, but these were the points that stuck with me.

Despite gathering a lot of attention (the game was showcased at Insomnia54 and other events throughout the UK, and was a semi-finalist for Microsoft's Imagine Cup award), Flatliners was never released.

More information (and a demo) can be found at the IndieDB page.