Nature of Code: Chapters 1 & 2
All of the vector work done up until now has been in 2 dimensions. This example showcases 3-dimensional vectors in a simple sketch. Written in Rust with macroquad.
This sketch attempts a simple 2D physics simulation. Pressing the Up arrow on your keyboard will cause the mover to accelerate, pressing the Down arrow will cause the mover to decelerate. If your key-presses are not being picked up, click inside the example "window" to allow the sketch to capture your key-presses. (Does not work on mobile.) Written in Rust with macroquad.
Controls
- Up - Accelerate
- Right/Left - Turn
- Down - Brakes
This example combines Exercises 2.1, 2.3, & 2.4. Utilizing a simple physics simulation, I've filled the balloon with helium and let it loose in the space. I am also creating a "wind" force, which is generated via a 3-octave perlin noise value. The edges exert an invisible force which pushes back against the balloon when hitting the top or side edges.
This exercise combines 2.6, 2.7, & 2.11 into one. In this example, I have a series of balls, and a series of forces being applied to these balls. There is a constant gravity force present, a wind force when Spacebar is pressed, and friction while the balls roll along the floor. In addition, you can grab and toss the balls by clicking on them. Note that you can grab and hold multiple balls at once, which allows you to see how their mass impacts the forces of friction and/or wind. Each ball's radius is a product of its mass.