Week 2 (17-23 Oct 2022)

In this week we looked at animation of objects in programming, this is important when developing games as it creates movement for the many features that the game could have. To assist in creating animation in coding, we can use mathematical formulas to help create non-linear speeds, for example exponential equations in which one value out of the two will increase exponentially. Here are some picture examples with equations:

y = 2^x (Exponential Increase)

y = (1/2)^x (Exponential Decrease)

We then moved onto putting easing functions to use with JavaScript, in this example it would create a canvas with several circles that had random colours, sizes and speed. After playing around with this script I decided to add squares with similar random attributes. I then decided to involve the easing function, so I implemented an exponential decrease to the speed of the shapes, this could be useful for simulating a loss in kinetic energy in objects.

We also covered two types of animation, Time based and frame based animation. The first of the two is animation which runs alongside the time elapsed from the start of the animation, this means that on slower machines the animation will appear to skip frames which can be better for online multiplayer games where everyone needs to be in sync. Frame based animation works by the frame, meaning that no frames will be skipped which is good for single player games where other players wont be punished for another player’s lag.

Leave a comment

Your email address will not be published.