Simple 3D Ground Demo

Here's a quick demo of something I threw together out of curiosity. Expect it to evolve into other stuff and feel free to play with it and experiment with it. It draws a pseudo 3d landscape with alternating colors.

WHAT TO EDIT IN THE CODE
CA and CB are the two colors of the ground.

ZMAX controls the number of 'steps' from the background to the foreground and also controls how many visible stripes scroll across it (which is DIV). It's best not to play too much with DV, but you're still welcome to noodle with it.

HZN is the pixel where the horizon line is on the vertical axis. I set a min/max on the @LOOP section, but you could easily change this and see what happens.

SPD is speed the lines move toward you. The further up you are away from the ground, the slower they are to simulate flying high above the landscape. When you get closer, the movement is faster like you're next to the ground. This too can be altered or removed but it looks weird when the speed of the scrolling doesn't change when you move up and down (which you'll see if you change this)

Everything else is just math on those things. The whole thing going on with it is that it draws a big box for from the horizon line to the bottom of the screen then just draws the 2nd color scaled as it gets closer to the bottom of the screen. The lines move faster as they get towards the bottom of the screen too, again to simulate distance.

The overall effect should remind you of old 8bit scrolling landscapes.

I plan on adding scaling sprites (signs, etc.) and maybe a road graphic too, if possible. It depends on CPU cycles left over since I do a lot of math between frames. I'll probably optimize it to remove all floating point math from the main loop except right before drawing...i.e. work with large whole numbers then multiply the final number by a decimal to get it's actual screen coordinant. For the moment, it works with floating points, which is probably not great.