Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
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.
In 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.
Read more about:
Featured BlogsYou May Also Like