NanoDoc Prototypes

Prototyping is essential to getting the feel of gameplay just right.  Here are two prototypes I built for NanoDoc:

Flocking

I used this prototype to figure out flocking algorithms, but it’s also a fun little toy to play around with. Basically, flocking is determined by 3 variables – Cohesion, Alignment, and Seperation. In the prototype, each “bird” acts independantly, based on the value of the three variables.

Cohesion – how close (positionally) a bird sticks to the average position of its neighbors
Alignment – how close (directionally) a bird sticks to the average vector of its neighbors
Seperation – how much distance a bird maintains from its neighbors.

By adjusting the weight of each of these variables, you can end up with some reallyl cool behavior.

Here are just a few screenshots of different settings:

Flock1: By default, with C, A, S = 1, there is very tight, jittery flocking behavior


Flock2: Without any cohesion, the birds will spread out a bit more, but still maintain flocking


Flock3: Without any cohesion or alignment, there’s no longer any flocking, just seperation


Flock4: Without C, A, S = 0, the birds will maintain whatever original velocity they had, without flocking


Flock5: With a low Cohesion, and A, S = 0, the birds will come together in a circular motion


Flock6: Adding in a little bit of seperation, the birds will now have a nice, gentle flocking motion. This is the behavior I eventually used in NanoDoc for the “swarming” bosses.

There are a huge number of variations that could be generated from these three variables, and probably lots of cool behavior I havn’t even discovered.

The flocking algorithm could also be improved by have different birds use different settings, or allowing variable speeds for birds. Right now all the weighted values are normalized, and the vectors are multiplied by the speed. If there was some sort of “smoothing” of the speed, you’d end up with even more realistic behavior you see in nature.

The windows install is here: http://daydalus.net/GameDev/Prototypes/FlockTest.zip

The source code is on bitbucket here: https://bitbucket.org/tdonlan/flock-test/src


Ball Collision

I used this prototype to figure out how the viruses would flow through the bloodstream in the game. I wanted to have naturalistic movement, and have the germs bump off each other, but not richochet around like billiard balls.


The main logic occurs here:

private Vector2 CheckOthers(Vector2 position, Vector2 Velocity)

{

for (int i = 0; i < game.balls.Count; i++)

{

if (BoundingCircle.Intersects(game.balls[i].BoundingCircle))

{

//push away from the center

Vector2 direction = BoundingCircle.Center - game.balls[i].BoundingCircle.Center;

if (direction.X != 0 && direction.Y != 0)

direction.Normalize();

direction *= game.CollisionVal;

Velocity += direction;

}

}

return Velocity;

}

Each ball checks all the neighbors using circle collision detection. If there is a collision, the ball moves away. The key is to “soften” the direction to push the ball. Right now I’m using .8. This value could be adjusted. A lower value makes the balls “squishier”. A higher value makes them “bouncier”.
Windows Install here: http://daydalus.net/GameDev/Prototypes/BallTest.zip

Source code on bitbucket here: https://bitbucket.org/tdonlan/balltest/src