Fandom

Petit Computer Wiki

Simple 3D Ground Demo

915pages on
this wiki
Add New Page
Comments4 Share
Exierion

QR Code For Pseudo 3D ground demo. EXERION name comes from name of the arcade game that gave me the idea.

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 CODEEdit

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 8-Bit 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 coordinate.  For the moment, it works with floating points, which is probably not great.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.