Operators: Mathematical

Objective

Students must use mathematical operators to perform calculations for game physics and positioning.

Evidence

Mathematical calculations in game components:

  • Ghost.js - Math.hypot(dx, dy) for distance calculation
  • Ghost.js - Speed calculations with multiplication and division
  • Multiple classes - Physics calculations (gravity, velocity, collision)

Implementation Details

  • Basic operators: addition (+), subtraction (-), multiplication (*), division (/)
  • Modulo (%) for remainder calculations
  • Exponentiation (**) for power calculations
  • Math object functions (Math.hypot, Math.sqrt, Math.abs, etc.)
  • Operator precedence and parentheses

Key Concepts

  • Arithmetic operators and precedence
  • Math object methods: Math.sqrt, Math.abs, Math.floor, Math.random, etc.
  • Distance calculations with Pythagorean theorem
  • Velocity and acceleration calculations
  • Rounding and truncating numbers