Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 3: Finishing the Game Loop

Info: the Math Library

You don’t have access to this lesson

Please register or sign in to access the course content.

The Math library is a collection of functions and constants that are useful for doing calculations.

They can be familiar numbers, like Math.PI, which will give you the number 3.14159… or operations like sine and cosine, which you can do with Math.sin and Math.cos

The Math library also has many different ways you can round a number:

  • Math.floor, used in the last step, always rounds down.
  • Math.ceil always rounds up.
  • Math.round will round to the nearest whole number, either up or down.
  • There are a couple of other less common options, like Math.fround and Math.trunc

You can also do exponents with Math.pow, or take a square root with Math.sqrt!

Check out the complete Math library here.