Inspiration
This project was inspired by experiments both in 3D rendering and Perlin Noise. I was originally doing the two independently when I realized I could use them in conjunction to randomly generate terrain.
What it does
To give the program control of your mouse, click anywhere inside the Pygame window. This will hide your mouse and allow you to move it to look around. To release your mouse, just click again. Looking around does not affect the motion of the car. Use the WASD keys to control the car: W and S to move forward and back and A and D to turn. You cannot turn unless you are moving.
How I built it
A lot of trigonometry! The terrain and the car are stored in a list of shapes, which are in turn lists of points, which are 3-dimensional co-ordinates [x, y, z]. Then all of the shapes are rotated to match the rotation of the camera object and then translated onto the screen. To get the third-person perspective, I had to rotate everything around a point that was not the viewpoint, which was more difficult than I anticipated.
Challenges I ran into
It was difficult originally to create noise algorithm, which is in fact slightly different than Perlin Noise, but was definitely inspired by it. It was very difficult to first figure out the math to draw a first-person perspective, then to draw a third-person perspective was difficult again. Unfortunately, I could not introduce colour in time. Getting the car to look good was also a challenge.
Accomplishments that I'm proud of
I am proud of the way the terrain is generated and rendered. This was difficult to accomplish and I managed it without using any libraries. I am also proud of the way the car tilts according to the terrain it is on.
What I learned
I learned heaps about Perlin Noise and the type of mathematics used in it (which is largely vectors) and the mathematics used in rotating and projecting 3-dimensional shapes onto a 2-dimensional screen (which is entirely trigonometry).
What's next for 3D world exploration game
Next I will try to make the car look more realistic and I will also add colour. I would also like to clean up the way the car tilts according to the terrain it is on.
Log in or sign up for Devpost to join the conversation.