Sunday, May 28, 2017

Status Effect Interactions

Status effects and their interactions are a critical component to making Agent Blue fun and most importantly interesting. Effects have two states in which they interact; on entities and on the ground.  In game we have implemented fire, water, oil, agent, sleep, stun effects and made them interact with each other and different enemies in unique ways. In its most basic form each element has an antagonistic element that it counteracts as well as one other element it interacts with. For example oil will be consumed and lit on fire but will be doused by water or crawling.



Take note: If while playing you notice little particles coming off your character it means you are being hit by an effect and if you change color... well then you are affected by some status and should look out!

Particles

For complex effects in graphics engines, using standard drawable types like image files can lead to memory and cpu-intensive operations, and the general solution for this is to use a Particle engine. Particle engines are named as such because their core renderable object, the Particle, is lightweight to draw to screen and update.

In Oak, we have four groups of particles:

  • Color particles, which can be assigned a start color and end color for however long they last, smoothly transitioning from one to the other.
  • Gradient particles, which are just like color particles but can have their particle be a circular or horizontal gradient, or something similar.
  • Sprite particles, which throw away 'being lightweight' and just serve as generators for sprite images or other renderable types in the engine like animations. 
  • Collision particles, which wrap around any other particle but contain a collision space so they can react to the game environment. 
Oak's particle engine is based off of CraftyJS's particle engine, with significant modifications (and written from scratch, as we're in a different language). Some settings a particle can have are how gravity affects them, how much they rotate per frame, how fast they move, what angle they move at, and so on. Below is a demo of how most of these effects change a single color particle source:


The code used to make this demo (which is an oak program) can be seen here, (although it needs some documentation!)

Sunday, May 21, 2017

Automated Cross Compilation in Go

Cross compilation has been touched on before for Go, but one thing about it was always a little frustrating to me, and that was that the manual redefining of environment variables for multiple compilations took a long time and required manual tuning.

There are two observations we can make that can change this, and can automate multiple compilations in way that's universal across platforms:

  1. You can call Go from within Go
  2.  exec.Command("go", "build", "-o", output, packageName).Run()  
    
  3. You can define environment variables from within Go
  4.  os.Setenv("GOOS", "windows")
     os.Setenv("GOARCH", "386")  
With this in mind, we can built a script in Go that automates cross compilation! For each OS/Arch pair we want to compile, we can set the environment variables and run go build with a unique output name. Because Go provides a list of all valid OS/Arch pairs, we can also write a script that accepts variable packages and pair definitions, and you can find that script here.

This doesn't change how long it takes, as compiling for 20 different platforms involves recompiling a lot of the Go standard library every time, but it does mean we don't need to sit around and wait for each compilation to end to write in the next pair to compile for, and because the script itself is written in Go, we know the script will work on all Go platforms, whereas bash would have issues with windows. 

Monday, May 15, 2017

Loot Distrubution

Today we will be talking about how we handle loot distribution and its place in Agent Blue's replay-ability. Loot distribution includes both the choice of loot items and how they are placed across the level which is both the total possible loot and the ease of access. The main goal here is create a consistent yet in the end randomized experience that lets us tailor level difficulty without sacrificing replay-ability.


Levels are created with a total value of items and a range of locations to place potential items. Each zone type has a different base distribution of item drops such as weapon types and consumables which when combined with item values and item locations helps ensure consistent level progression across games. Given these parameters we spawn a series of potential item distributions which we then evolve over a period of generations to get closer to the target item value dictated by the level. We can add new rules to manipulate the item distribution to create a different feel for each level or to mix up the balance later. At the moment we are starting with fairly simple mutation process which will change a single attribute or item per generation but we will also be able to do more complex crossover and mutation chances to create more complex and diverse distributions.


With the levels generated players are given an abstracted view of what a level has to offer and get to choose which path to follow. Having generated a set of items the levels then place the items across the provided locations (which is often in locked goody rooms). It is possible for the player to get all of the loot if they traverse the level carefully. Beware there may be rooms with loot locked by your original keycard color which there might not be a re-encoder for on the level!

Sunday, May 14, 2017

Into The Forest We Go

So up to this point, Agent Blue has been using a basic interior design for the terrain. This was helpful for early development since the hard lines and machined patters are easy to do and make look nice using the tiled system that we are using.


A new addition is the forest area. Being a more natural area the hard, straight lines that were used before won’t work but there is still a need to conform to the tile system that is used for level generation. The way that the new forest tiles are drawn currently no two consecutive tiles should be more than one pixel off on the border height so that they flow from one to the other. The only concern currently for this tile set is that they may become too repetitive when there are long stretches of the same tile. As development continues these tiles may get an update or new additions to fix this issue. Until then I hope you enjoy your walk in the park.