3 ms·
I've made arcade side scroller with potentialy infinite world. Everything (terrain, objects, backgrounds) was created on the fly, basing on the coordinates of t
by ajuc 15y ago
I've made arcade side scroller with potentialy infinite world. Everything (terrain, objects, backgrounds) was created on the fly, basing on the coordinates of the player.
It wasn't really infinite, but only because coordinates would wrap at 32 bit, if you fly far enough into one direction (but I've never had the patience to test this).
It's linux only, and not very playable, but if you want to test it - it's here http://alan.umcs.lublin.pl/~ajuc/programy/gry/hw3/ http://alan.umcs.lublin.pl/~ajuc/programy/gry/hw3/
It requires libraries SDL, SDL_image, SDL_ttf, SDL_mixer, paragui (version >= 1.1.8). Works with software rendering so no acceleration needed.
I've been quite satisifed with terrain generation - I've calculated noise value (a few octaves of 2d Perlin noise) for every tile on screen, tiles with noise values over bias were solid, others were empty. I hadn't checked if there's always way out, but after tuning amplitudes and frequencies of noise generator I've never had problems with that in game.
Then I've had look up table that returned tile depending on which neighborns are solid and which are not. To cut the number of tiles I needed to draw I've used hex-like layout - every second row of rectangular tiles were shifted half an tile to the right. Thanks to that every tile had only 6 neighbourns, instead of 8. So I've needed 128 instead of 512 tiles. And it made levels look more "organic", than with regular 2d grid.