Jump to content

Wrapping (overflow)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by AnAj (talk | contribs) at 16:22, 5 July 2007 (Categorizing article - You can help!). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, wrapping is when a variable that exceeds its maximum value returns to its minimum value and vice-versa. Most 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.