GAME JOBS
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
June 19, 2013
 
2K Marin
Lead Network Programmer - 2K Marin
 
Insomniac Games
FX Artist
 
2K Marin
Lead AI Programmer - 2K Marin
 
Bluepoint Games, Inc.
Senior Graphics Programmer
 
2K China
2K Concept Artist - 2K China
 
Wahoo Studios, Inc
PR and Marketing Director
spacer
Blogs

  Two types of one-directional terrain animation
by Dan FitzGerald on 01/21/13 03:36:00 pm   Featured Blogs
Post A Comment Share on Twitter Share on Facebook RSS
 
 
The following blog was, unless otherwise noted, independently written by a member of Gamasutra's game development community. The thoughts and opinions expressed here are not necessarily those of Gamasutra or its parent company.

Want to write your own blog post on Gamasutra? It's easy! Click here to get started. Your post could be featured on Gamasutra's home page, right alongside our award-winning articles and news stories.
 

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.

 
 
Comments


none
 
Comment:
 




 
UBM Tech