After edits that makes things easier. Check out this topic: How do I generate a smooth random horizontal 2D tunnel?
- Initialize paths for
SCREEN_WIDTH + BUFFER_WIDTH
pixels. - Every time you go further, add more curves, but don't remove old (as you can go back)
- I suggested curves, because pixels take more memory, though they might still be OK.