Wrapping (overflow)

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In computing, wrapping is when a variable that exceeds its maximum value returns to its minimum value and vice-versa. Many high-level programming languages avoid wrapping by giving an arithmetic overflow error if this occurs.

Camera wrapping is a technique often used in video games, which allows a player to move in a straight line and get back to where they started. This was more often used in older games to make it seem that the player is moving up or down an extremely high hill; memory can be saved by using wrapping instead of creating a larger area filled with unpassable walls:

  • With wrapping:
--\  \  \
   \  \  \
    \  \  \--
  • Without wrapping:
--\
   \
    \
     \
      \
       \
        \
         \
          \--

As the diagrams above show, using wrapping will reduce the size of the area needed.

Camera wrapping can also be used to simulate the surface of a cylinder or torus.