In this project, we're going to build a basic 3D driving simulator! Check it out!
1) Go to the link below and click "Remix" at the top. This will get us our backdrop and an important block: "Draw Line From To"! We will use it many times. Don't worry if you don't understand, we are only learning how to use it today!
2) The first thing you'll notice is that the remix came with a sprite! Called Drawer? It's a purple dot? Weird! That's because in 3D we DON'T use sprites AT ALL. That dot is hidden and you'll never see it! Instead, in the Drawer sprite, we'll write all of our code to 'draw' the 3D models.
Find the "Draw Line From To block" in the "My Blocks" category. Use it to draw a white line on the road. Remember this is 3D, so you'll need to think about Z now! Don't worry about the variables that came with the remix just yet. Focus on drawing a line.
3) Figure out how to erase your line! Then code it to repeatedly erase and draw your road line again and again. Once you do that, show these variables:
camera X
camera Y
camera Z
Play around with them. What happens when you change X? Y? Z? What are these variables for? What do they mean? Change the Z-coordinates of your line a few times using the "Draw From Line To" block. Can you make the line start at different places closer and farther from the screen? Z is just like X and Y except it's the direction leading OUT OF THE SCREEN. Remember that towards the screen is the negative Z direction.
4) Now show one more variable: timer! You can find this one in the "Sensing" category. It's the number of seconds that have passed since the game began! Open up a new project and try using timer, the "mod" operator, and some number in a loop, saying the calculation. What do you notice? How can this be useful in controlling the position of something that moves in loops?
Use this concept and the Z-coordinates of your line to make your line move down the screen. You may need to multiply it by a bigger number to get it moving fast!
5) Then add more lines!
6) Now for a tree! Use what you learned about road lines to make a tree on the side of the road. It should move towards you just like the road lines.
7) You guessed it. Make a second tree.
8) And then make them start at different spots! By now your code must be sooooooo long. Maybe you should make some "My Blocks" to help you keep it short and clean?
9) Last but not least, model you a car! It doesn't need to move, but don't let that make you think it'll be easy! This is your final challenge! Great Work!
Bonus) Add steering! And don't let us stop you there: acceleration/deceleration for your car might be cool. What about the variable FOV? Hmm what does that do?