Math in gameprogramming can be as easy as adding a+b, to calculating and manipulating trigonometricswith added variables while stringing it to its function, but there is way morecomplicated and advanced ways to use calculus in game development.Some of the mostimportant maths used in game development :- Trigonometrics(Since these functions take a lot of time to calculate, in a computer game youwould generally store them in a look-up table. They are useful in convertingbetween polar and Cartesian co-ordinate systems)- Domainand Range- Delta TimeMath is everythingwhen it comes to gaming development .
The most basic of games use some form ofmath to the most complex of games. A character wouldn’t be able to aim andshoot from his gun, nor jump and run on a selected area without the help of maths. Even pac-man uses some sort of mathematics . Let’s see the math behind somepopular games right now :What are the mechanics behind the jump ofMario from a block to another one in this game?When Mario jumps froma block to another one , he is changing his x-axis positioning , but when hejumps , his positioning on the Y-axis changes too because the character is adjustinghis position vertically when he jumps , and horizontally when running .
Forevery place in this game , it is assigned with points on the x-yaxis . So when Mario is jumping , he is forming a parabola.Why a character survices when he falls downfrom a 2 story building ,but dies when he falls from a 4 story building , whatis the math behind this ?As we said before ,everything is related to math , so assuming ‘d’ is a 2 story building which is20 ft or 6 m tall , and ‘a’ is the acceleration due to gravity ( a=10 m/sapprox..
)A=v/t ; V=at and d=6mSo t = sqrt(2x6m)/10m/s2 —à t=1.2 sThe guy would makecontact with the floor in 1.2 secV= 10m/s2x 1.2sThat’s about 12m/sConverting back tokmh , its about 38 km/h Lets say the weightof the body is 70kg F=ma , 70 x (12m/s /1.2 s )= 70 x 10 = 700 N of force ( approx..).
An acceleration of 12m/s with 700 N of force wont affect the character too much in real life .So they code that inthe registery of the game , that if the character fall with an accelerationspeed less than 15 mph and less than 800 N , the guy would loose 20 % of hishealth and he will get some bruises and scratches .They redo this equation forgreater acceleration speed and force . All thosecalculations happens when we are playing games but we don’t see them nor payattention to them . Math in game development is simulated eitherby the developer or handled by the engine at runtime by running computations tocalculate the operation that is needed.
Lets see some events in popular video gamesthat require a lot of mathematical equations :-Those oceans wavescrashes adapting smoothly to your swimming movement in GTA5? Math.-Them bullets hittingyou in your head, killing you instantly ? Math.-Drifting arout thatcone in Midnight Club Remix ? Math.-Changing your speedon a highway while forcing longer on the R2 button in Need for speed ? Math.-Launching this birdin the air to destroy a base with a specific velocity and angle in angry bird ?Math.Here , we are going to see the equations andthe math related to the launch of a bird in this popular game angry birds :Angry Birds is a video game franchise created by Finnish companyRovio Entertainment. The series focuses on multi-colored birds who try to savetheir eggs from green-colored pigs, their enemies.
This is done by the birds launching themselves out of a giant slingshot andhitting the pigs various constructs, then eliminating them. · Much of angry birds comes down to choosing theangle to sling the bird through the air! Birds initial angle out of theslingshot equals the angle between the horizontal and the stretched sling atthe moment of release. The angle determines the path the bird will follow inthe air. How would you launch thebird so that it lands in front of the tower without hitting anything but theground? Keep in mind that every time you change the launch angle for the bird,you are predicting its path.
Mathematically,Parabolas can be written as y = ax² + bx + c. Choosing specific values for a,b, and c defines a curve. In Angry Birds, if you find the right a, b, and cdefines a curve the birds enact their revenge on the pigs and their fortresses.Thisis the parabola created after the bird is launched in the skyNowhere is a parabola that is in the form y= a(x-h)²+k . The equation for thatparabola is y=0.6(x-12)²+14The0.6 represents the stretch of the parabola . The(x-12)2 represents the shift the parabola undergoes .
This parabolashifts to the right because it is negative 12 . The squared make the equation aparabola.Nowfor the final part, the +14 represents where the parabola hits the y-axis .That was a brief explanation of the relationshipbetween calculus and the fly of the bird in this game .Mathis an essential ingredient that is necessary to the production of games.
Without the use of math in games we would just have pretty art that’ssemi-interactive. Math adds a whole new element to entertainment by blendingthe sciences and arts into a whole.Withthat being said, mathematics allows games to do incredible things that the realworld cannot simulate by allowing new ways for the game script and engine tohandle calculations on the fly that would not be feasible to do in the realworld. So next time when you question your math teacher if you’re going to everuse “Algebra” in the real world when you’re done with your studies, yousure will especially if you pursue a career in game development.