Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
October 20, 2017
arrowPress Releases

If you enjoy reading this site, you might also want to check out these UBM Tech sites:


Two types of one-directional terrain animation

by Dan FitzGerald on 01/21/13 03:36:00 pm   Featured Blogs

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.


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.


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.


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.

Related Jobs

Infinity Ward / Activision
Infinity Ward / Activision — Woodland Hills, California, United States

Senior AI Engineer
Wargaming Sydney
Wargaming Sydney — Sydney, New South Wales, Australia

Senior Software Engineer – C++, Game Tech Development, Render
Insomniac Games
Insomniac Games — Burbank, California, United States

Engine Programmer
Phosphor Games Studio
Phosphor Games Studio — Chicago, Illinois, United States

Mid to Senior Gameplay Programmer

Loading Comments

loader image