Numbers in My Game

What Are Numbers?

Numbers are numeric values used for calculations in programming.

Games rely heavily on numbers for:

  • movement
  • scoring
  • positions
  • distances
  • timing
  • animations

My game uses numbers constantly to control gameplay behavior.


Why Numbers Are Important

Without numbers, the game could not:

  • move characters
  • calculate collisions
  • track score
  • control speed
  • position objects on the screen

Numbers are one of the most important data types in game development.


Example 1: Score Values

My game uses numbers to track score.

this.score += points;

Explanation

This line:

  • adds points numerically
  • updates the player’s score
  • changes the scoreboard value

Another example:

this.score -= points;

This subtracts points after collisions.


Example 2: Player & Enemy Positions

Numbers are used for object positioning.

INIT_POSITION: {
  x: width * 0.7,
  y: height * 0.6
}

Explanation

The x and y values:

  • determine screen position
  • place objects in the game world
  • control where entities spawn

Example 3: Movement Speed

Numbers control movement speed.

const speed = 2.2;

Explanation

This number affects:

  • how fast enemies move
  • player chasing behavior
  • gameplay difficulty

Different speeds create different enemy behaviors.


Example 4: Collision Distance

Numbers are used in collision detection.

if (dist < 40)

Explanation

This checks:

  • whether objects are close enough to collide
  • when damage should happen
  • when interactions should activate

Distance calculations rely on numbers.


Example 5: Animation Timing

Numbers control animation speed.

ANIMATION_RATE: 100

Explanation

This controls:

  • how quickly sprites animate
  • smoothness of motion
  • visual timing in the game

Example 6: Loop Counts

Numbers are used to generate multiple objects.

Array.from({ length: 10 })

Explanation

This creates:

  • 10 goldfish objects
  • repeated game entities
  • scalable object systems

Example 7: Mathematical Calculations

Numbers are used with math functions.

this.position.x += Math.cos(angle) * speed;

Explanation

This calculation:

  • moves enemies toward the player
  • updates position continuously
  • creates smooth movement

Game physics and AI rely on numerical calculations.


Why Numbers Help My Game

Numbers improved my project by:

  • controlling movement and physics
  • managing score systems
  • handling collision detection
  • enabling animations
  • supporting enemy AI behavior

Without numbers, the game could not function properly.