informa
/
2 MIN READ
Featured Blog

Two types of one-directional terrain animation

I recently rewrote the terrain animation system for my game Dog Sled Saga to allow random tiles of different lengths to be added on the fly.

Dog Sled Saga screenIn Dog Sled Saga, the terrain you traverse only moves leftward, and there are several layers of terrain at different distances from the "camera." At first, we only had one terrain tile per layer, which allowed for a fairly simple animation routine. As we begin to make new tiles of various lengths, though, a rewrite was necessary.

Originally, when the layers of terrain were made up of identical tiles of equal width, each layer was a block of tiles wide enough to cover the screen width, plus one extra.

Each layer slid left at its set parallax speed, and once it had moved the distance of one tile width (i.e. the leftmost tile was completely off-screen) it would bounce back to the right the distance of one tile width. The apparent motion of the terrain was seamless, and no more tiles were produced than needed.

tile-block-shift

This system was been in place since back when I had plain quads with colored edges for terrain. However, I knew that this was a placeholder system. We planned to be able to have randomized tiles of arbitrary width, with things like buildings, patches of grass, snow drifts, mountains, and so on. This cannot work if the terrain layer is a set block.

I wrote a new system that cuts tiles off the left edge of the layer when they leave the screen and adds new ones (with shufflebag randomization based on a C# tutorial that I didn't struggle to implement in AS3) to the right as soon as the exposed right edge of the layer is about to appear. Common tiles are drawn from a Loanshark-based object pool (when they are removed, they are made available to be reused, so new tile objects aren't created every time) while rare tiles are produced as needed.

tile-cutting-and-adding

There's only one irregularly sized tile so far, but this opens the door for many more to come.

Soon, I want to do a similar rewrite of the system that places track entities like obstacles and restock points. Right now, they are set when the race starts, and activated/deactivated as enter/leave the screen. I want to queue them on the fly and do better recycling like I did with the terrain tiles. This will open the door for an endless mode.

Latest Jobs

Treyarch

Vancouver, BC, Canada
5.8.23
Producer

Bladework games

Remote (United States)
5.18.23
Senior Gameplay Engineer

University of Canterbury

Christchurch, Canterbury, New Zealand
5.17.23
Academic in Game Arts and Animation

Fred Rogers Productions

Hybrid (424 South 27th Street, Pittsburgh, PA, USA
5.19.23
Producer - Games & Websites
More Jobs   

CONNECT WITH US

Explore the
Advertise with
Follow us

Game Developer Job Board

Game Developer

@gamedevdotcom

Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Browse
Advertise with

Game Developer

Engage game professionals and drive sales using an array of Game Developer media solutions to meet your objectives.

Learn More
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more