Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Vector Arithmetic and Vector Drawings [10/10]

Here is the random jumping rotating zombie program.

To slow down the jumping-around speed, change the value of variable speedMul to 0.5, or even to 0.3.

This size of this program prevents easy analysis. Besides that, the program employs linear interpolation, which involves a bit of mathematics. But, if you feel like it, with some peristence you can analyze and understand the program.

The resulting position is linearly interpolated between positions posStart and posEnd. This can be easily observed while the program is running, especially when it is slowed down.

The formula for linear interpolation between any two numbers, for example between angles a1 and a2 is:

  • angle = a1 + t*(a2-a1)

In this formula, t is some number between 0 and 1. When t is close to 0, the resulting angle is close to angle a1. When t is close to 1, the resulting angle is close to angle a2.

Loading...