The emphasis of this discussion is on making splines useful, specifically useful for real-time applications, where update time is critical, and getting stuck in update loops is a big no-no. Splines are a tool that many developers are familiar with, but there is some quirkiness to dealing with splines in practice.

In this first article I will give a short introduction to splines and their usefulness for the wind currents in Seabird. I will also show how to get the slope and sharpness of the spline curve given any place on the spline. In part 2, I will show how to get the total length of the spline, and also how to find the closest point on the spline from any point in the world. In Part 3, I will show how to achieve a constant speed when moving along a spline path, given that you start with a spline where the control points are not at an equal distance from each other along the length of the spline.

To start off, a spline is defined by a set of control points. The placement of these control points give the shape of the spline. Between each consecutive set of control points there is a spline segment. Each segment is usually a cubic polynomial. The construction of a spline is such that all of the ends of these polynomials match up, and their first and second derivatives also match up, so that the spline can be treated like a single continuous parametric curve.

If this is the first segment of the spline, then increasing x from 0 to 1 should interpolate smoothly from the first control point to the second control point. I have written A, B, C, and D as the coefficients for simplicity, but in the 2D case each of these coefficients have x and y components, so this is really 2 equations, one for each dimension:

The equation for a higher dimensional spline segment is the same, given that there is an equation for each additional dimension.

In the cubic polynomial, D is the control point at the beginning of the segment. A, B, and C, are coefficients chosen such that when x is equal to the segment index we get D, the control point for the segment, and when x is equal to the segment index plus one, we get the control point at the beginning of the next segment in the spline. We then switch to using the polynomial of the next segment to smoothly interpolate to the third control point, and so on. The spline is also setup so that the first derivative and second derivative of the polynomials match up, so that moving along the spline path is smooth and continuous.

Splines are useful for the inner workings of the wind paths in my game Seabird. In Seabird, the characters are birds which are able to fly in wind currents that exist throughout the game. It is important that the movement of the characters through the wind currents appear smooth. I use splines to achieve this smooth movement.

One of the first tasks that you may want to do when working with splines is to find a vector facing down the spline from a given place on the spline. In Seabird, the speed the player is able to move faster down the wind current is proportional to how well their user input vector is aligned with the vector facing down the current. The vector facing down the current naturally is the current's slope or first derivative, which we can find by the power rule from calculus:

If we use this equation in place of the original polynomial, then we get the slope at any given point on the spline. Notice how the D coefficient has disappeared. This is because the slope of the spline is not related the placement of the spline in the world. The slope of the spline should be the same no matter whether the spline is in China or Peru.

Another thing we might want to know is whether the spline is pinching tightly. This happens when the path has a sharp change in direction. We can find this by solving for the second derivative of the polynomial:

We have seen the basic idea behind splines, and a few useful tools for knowing a little bit more about how the spline behaves. In the next article we will discuss how to get the total length of the spline. We will also discuss the problem of finding the closest point on the spline to any other point in the world. This can be useful in collision detection, because we need to know if an object is close enough to the spline to determine if it is overlapping.

What is the game about?

Seabird is a game where you play as a bird that is having trouble flying. The goal is to find your flock, who are looking for you.

Gameplay:

Seabird is a rogue-like game as far as procedural generation and permanent death of the player-character. The rest of the gameplay is different than other rogue-like games. It involves trying to find your way back to your flock by navigating through the environment and learning the behavior of the other birds that might be able to help you find your flock again. If you are not able to learn to work with the other birds, you will eventually fall into the ocean below.

World:

Instead of a dungeon or a castle, Seabird takes place in the air. The game takes place in a 2D side-view environment. There are wind currents, gusts, vortexes, and all sorts of other wind formations. In Seabird, everything in the level is dynamic. The currents move around, disappear, and change form on screen.

Feel and Aesthetics:

I am going for a storybook feel for the game.

Visually Seabird will have vibrant cloudscapes and mesmerizing wind patterns, as well as a focus on character design.

The music will be acoustic and melodic.

I feel that the handmade network is a good place for this project for at least two reasons:

1. I have found the people here helpful and supportive, and I think this community will be valuable to help Seabird come together.

2. I care about learning how things work. This has influenced the choices of technology in the game which makes it fits nicely with the other projects here.

I started working on Seabird in 2016. Seabird started as a simple prototype. In the prototype there were a number of squares that would stay near other squares of their same color on the screen. The player controlled a square that was falling. If the player was near other squares, then the player would stop falling, but the other squares do not always want the player near them. To avoid falling, the player needs to understand how the other squares react to the things the player does.

For instance, upon going near a group of squares of the same color, the squares may initially be interested in the player because they have not seen the player before. After some time the squares may become uninterested, but other squares in the same group may still want to continue to help the player. The squares trying to help will then try to get their uninterested friends to come help.

The white gauges above each square was used to represent how much each square was willing to help you.

I also made a prototype of the player controls and character dialog.

(I guess the answer to the question in that dialog is (if you look closely) their wings are not entirely connected to their body.)

The only thing I am trying to do with Seabird is to make interesting character interactions between the player and other characters.

I would like to get closer to understanding better how interactive fiction could work in a game, but I am content for now with making a game that has interesting and challenging character interactions, regardless of whether the sum of the interactions emerges into a tight narrative.

I hope to share the development of Seabird through streams and posts here on this blog.

I would like to do a live stream demonstration whenever I have some notable update on the game. This way I can share the progress of the game design, technology, and artwork.

You can reach me on twitter or leave a message here if you have any questions or thoughts. I would like to hear from you.