Box2D
   HOME

TheInfoList



OR:

Box2D is a free
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
2-dimensional In mathematics, a plane is a Euclidean ( flat), two-dimensional surface that extends indefinitely. A plane is the two-dimensional analogue of a point (zero dimensions), a line (one dimension) and three-dimensional space. Planes can arise as ...
physics simulator
engine An engine or motor is a machine designed to convert one or more forms of energy into mechanical energy. Available energy sources include potential energy (e.g. energy of the Earth's gravitational field as exploited in hydroelectric power gen ...
written in
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
by Erin Catto and published under the
MIT license The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license comp ...
. It has been used in ''
Crayon Physics ''Crayon Physics Deluxe'' is a puzzle video game designed by Petri Purho and released on January 7, 2009. An early version, titled ''Crayon Physics'', was released for Windows in June 2007. ''Deluxe'' won the grand prize at the Independent Games ...
Deluxe'', ''
Limbo In Catholic theology, Limbo (Latin '' limbus'', edge or boundary, referring to the edge of Hell) is the afterlife condition of those who die in original sin without being assigned to the Hell of the Damned. Medieval theologians of Western Euro ...
'', ''
Rolando Rolando may refer to: Entertainment *'' Rolando'', a 2008 puzzle-adventure video game *'' Rolando 2: Quest for the Golden Orchid'', a 2009 puzzle-adventure video game *"Rolando", a song by Roland Kirk from the album ''Domino'' People *Rolando (gi ...
'', ''
Incredibots IncrediBots is a physics simulation game and series produced by Canadian studio Grubby Games and was later purchased by Big Fish Games. It uses the Box2D physics engine, which allows objects created in a simple click and drag fashion to interac ...
'', ''
Angry Birds ''Angry Birds'' is a Finnish action-based media franchise created by Rovio Entertainment. The game series focuses on the eponymous flock of angry birds who try to save their eggs from green-colored pigs. Inspired by the game ''Crush the Castl ...
'', ''
Tiny Wings ''Tiny Wings'' is an iOS game developed by German game developer Andreas Illiger, released on February 18, 2011. It was the top-grossing game in the App Store for two weeks from late February to early March 2011. The app was voted best iPhone ...
'', ''
Shovel Knight ''Shovel Knight'' is a platform game, platform video game developed and published by Yacht Club Games. Development was crowdfunded and the game was released for Nintendo 3DS, Wii U, and Windows in June 2014. It was ported to OS X and Linux in Se ...
'', ''
Transformice ''Transformice'' (sometimes abbreviated to ''TFM'' or ''T4M'') is an online independent multiplayer free-to-play platform video game, created by French game designers, known by their aliases Melibellule and Tigrounette. Melibellule produces the ga ...
'', ''
Happy Wheels ''Happy Wheels'' is a ragdoll physics-based platform browser game developed and published by Fancy Force. Created by video game designer Jim Bonacci in 2010, the game features several player characters, who use different, sometimes atypical, vehi ...
'', and many online Flash games, as well as iPhone, iPad and Android games using the
Cocos2d Cocos2d is a free software framework. It can be used to build games, apps and other cross platform GUI based interactive programs. Cocos2d contains many branches with the best known being Cocos2d-objc, Cocos2d-x, Cocos2d-html5 and Cocos2d-XN ...
or Moscrif game engine and
Corona Corona (from the Latin for 'crown') most commonly refers to: * Stellar corona, the outer atmosphere of the Sun or another star * Corona (beer), a Mexican beer * Corona, informal term for the coronavirus SARS-CoV-2, which causes the COVID-19 di ...
framework.


History

Box2D was first released as "Box2D Lite", a demonstration engine to accompany a physics presentation given by Erin Catto at GDC 2006. On September 11, 2007, it was released as open source on
SourceForge SourceForge is a web service that offers software consumers a centralized online location to control and manage open-source software projects and research business software. It provides source code repository hosting, bug tracking, mirrorin ...
. On January 17, 2010, Box 2D moved the project to
Google Code Google Developers (previously Google Code) , application programming interfaces (APIs), and technical resources. The site contains documentation on using Google developer tools and APIs—including discussion groups and blogs for developers usin ...
for hosting. On July 12, 2015, hosting was moved again, this time to
GitHub GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, continuous ...
. On March 6, 2008, version 2.0 was launched, introducing
continuous collision detection Collision detection is the computational problem of detecting the intersection (Euclidean geometry), intersection of two or more objects. Collision detection is a classic issue of computational geometry and has applications in various computing ...
and revamping the
API An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
. On July 27, 2020, version 2.4 was launched, with a variety of changes, most notably the license was changed to the
MIT License The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license comp ...
.


Cross-platform availability

Box2D is itself written in platform-independent
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
(usable on any system with a C++ compiler available). The engine may be compiled in fixed point and
floating point In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. For example, 12.345 can be ...
modes, and has been used on the
Nintendo DS The is a handheld game console produced by Nintendo, released globally across 2004 and 2005. The DS, an initialism for "Developers' System" or "Dual Screen", introduced distinctive new features to handheld games: two LCD screens working in tan ...
,
Wii The Wii ( ) is a home video game console developed and marketed by Nintendo. It was released on November 19, 2006, in North America and in December 2006 for most other Regional lockout, regions of the world. It is Nintendo's fifth major ho ...
, and several mobile phones (including Android,
BlackBerry 10 BlackBerry 10 is a discontinued proprietary mobile operating system for the BlackBerry line of smartphones, both developed by BlackBerry Limited (formerly Research In Motion). BlackBerry 10 is based on QNX, a Unix-like operating system that was o ...
and
iOS iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also includes ...
) as well as most major operating systems. The engine has been ported to many other programming languages and environments, including
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
,
Adobe Flash Adobe Flash (formerly Macromedia Flash and FutureSplash) is a multimedia Computing platform, software platform used for production of Flash animation, animations, rich web applications, application software, desktop applications, mobile apps, mo ...
(in
ActionScript ActionScript is an object-oriented programming language originally developed by Macromedia Inc. (later acquired by Adobe). It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript (meaning i ...
and
Haxe Haxe is an open source high-level cross-platform programming language and compiler that can produce applications and source code, for many different computing platforms from one code-base. It is free and open-source software, released under the ...
languages), C#,
Lua Lua or LUA may refer to: Science and technology * Lua (programming language) * Latvia University of Agriculture * Last universal ancestor, in evolution Ethnicity and language * Lua people, of Laos * Lawa people, of Thailand sometimes referred t ...
,
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, and D. Bindings exist to use the compiled library from
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
, DarkBASIC and
BBC BASIC BBC BASIC is a version of the BASIC programming language released in 1981 as the native programming language for the BBC Micro home/personal computer, providing a standardized language for a UK computer literacy project of the BBC. It was wr ...
. On October 30, 2009, it was announced that Box2D was being integrated into the (now older) Torque 2D game engine.


Programs that use the engine


BBC Basic for SDL
cross-platform version of
BBC Basic BBC BASIC is a version of the BASIC programming language released in 1981 as the native programming language for the BBC Micro home/personal computer, providing a standardized language for a UK computer literacy project of the BBC. It was wr ...
*
BlitzBasic Blitz BASIC is the programming language dialect of the first Blitz compilers, devised by New Zealand-based developer Mark Sibly. Being derived from BASIC, Blitz syntax was designed to be easy to pick up for beginners first learning to program. T ...
* GameMaker: Studio, uses the engine for physics simulation. *
LibGDX libGDX is a free and open-source game-development application framework written in the Java programming language with some C and C++ components for performance dependent code. It allows for the development of desktop and mobile games by usi ...
, uses the physics engine for games and lighting. * Stencyl, uses the physics engine for games, and allows export to Flash and iOS. *
Unity Unity may refer to: Buildings * Unity Building, Oregon, Illinois, US; a historic building * Unity Building (Chicago), Illinois, US; a skyscraper * Unity Buildings, Liverpool, UK; two buildings in England * Unity Chapel, Wyoming, Wisconsin, US; a h ...
* Construct2 * LÖVE, uses the physics engine for games *
Solar2D Solar2D (formerly Corona SDK) is a free and open-source, cross-platform software development kit originally developed by Corona Labs Inc. and now maintained by Vlad Shcherban. Released in late 2009, it allows software programmers to build 2D m ...
*
Clickteam Fusion 2.5 Clickteam is a French software development company based in Boulogne-Billancourt, Hauts-de-Seine. Founded by Francis Poulain, François Lionet and Yves Lamoureux, Clickteam is best known for the creation of Clickteam Fusion, a Scripting language ...

Flame
Flutter game engine


Features

Box2D performs constrained
rigid body In physics, a rigid body (also known as a rigid object) is a solid body in which deformation is zero or so small it can be neglected. The distance between any two given points on a rigid body remains constant in time regardless of external force ...
simulation. It can simulate bodies composed of
convex polygon In geometry, a convex polygon is a polygon that is the boundary of a convex set. This means that the line segment between two points of the polygon is contained in the union of the interior and the boundary of the polygon. In particular, it is a ...
s,
circle A circle is a shape consisting of all points in a plane that are at a given distance from a given point, the centre. Equivalently, it is the curve traced out by a point that moves in a plane so that its distance from a given point is const ...
s, and edge shapes. Bodies are joined with
joints A joint or articulation (or articular surface) is the connection made between bones, ossicles, or other hard structures in the body which link an animal's skeletal system into a functional whole.Saladin, Ken. Anatomy & Physiology. 7th ed. McGraw- ...
and acted upon by
force In physics, a force is an influence that can change the motion of an object. A force can cause an object with mass to change its velocity (e.g. moving from a state of rest), i.e., to accelerate. Force can also be described intuitively as a p ...
s. The engine also applies
gravity In physics, gravity () is a fundamental interaction which causes mutual attraction between all things with mass or energy. Gravity is, by far, the weakest of the four fundamental interactions, approximately 1038 times weaker than the stro ...
,
friction Friction is the force resisting the relative motion of solid surfaces, fluid layers, and material elements sliding against each other. There are several types of friction: *Dry friction is a force that opposes the relative lateral motion of t ...
, and
restitution The law of restitution is the law of gains-based recovery, in which a court orders the defendant to ''give up'' their gains to the claimant. It should be contrasted with the law of compensation, the law of loss-based recovery, in which a court o ...
. Box2D's collision detection and resolution system consists of three pieces: an incremental
sweep and prune In physical simulations, sweep and prune is a broad phase algorithm used during collision detection to limit the number of pairs of solids that need to be checked for collision, i.e. intersection. This is achieved by sorting the starts (lower boun ...
broad phase, a
continuous collision detection Collision detection is the computational problem of detecting the intersection (Euclidean geometry), intersection of two or more objects. Collision detection is a classic issue of computational geometry and has applications in various computing ...
unit, and a stable linear-time contact solver. These algorithms allow efficient simulations of fast bodies and large stacks without missing collisions or causing instabilities.


Related engines

An earlier version of the Box2D engine, now known as Box2D Lite, was released primarily for educational purposes, based on a series of yearly
Game Developers Conference The Game Developers Conference (GDC) is an annual conference for video game developers. The event includes an expo, networking events, and awards shows like the Game Developers Choice Awards and Independent Games Festival, and a variety of tutori ...
presentations that Erin Catto has given. Box2D Lite uses many of the same algorithms as Box2D, but has a smaller feature set. The
Chipmunk Chipmunks are small, striped rodents of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia. Taxonomy and systematics Chipmunks may be classified either as ...
physics engine (written in C) and Phys2D (written in Java) are both partially based on Box2D Lite. The physics engine used in SpriteKit for iOS and OS X uses Box2D internally. The LiquidFun physics engine is a fork of Box2D by
Google Google LLC () is an American multinational technology company focusing on search engine technology, online advertising, cloud computing, computer software, quantum computing, e-commerce, artificial intelligence, and consumer electronics. ...
, which adds
fluid simulation Fluid animation refers to computer graphics techniques for generating realistic animations of fluids such as water and smoke. Fluid animations are typically focused on emulating the qualitative visual behavior of a fluid, with less emphasis place ...
to the engine.
LibGDX libGDX is a free and open-source game-development application framework written in the Java programming language with some C and C++ components for performance dependent code. It allows for the development of desktop and mobile games by usi ...
uses a Java wrapper around native Box2D code written in C++ as its physics engine.


Articles

Itterheim and Wenderlich describe the usage of Box2D in the
Cocos2d Cocos2d is a free software framework. It can be used to build games, apps and other cross platform GUI based interactive programs. Cocos2d contains many branches with the best known being Cocos2d-objc, Cocos2d-x, Cocos2d-html5 and Cocos2d-XN ...
iPhone engine. An article in the Adobe Edge newsletter discusses the use of Box2D in Flash games.


See also

*
Chipmunk (software) Chipmunk2D is a 2-dimensional real-time rigid body physics engine written by Scott Lembcke that is designed to be portable, lightweight, fast, and easy to use. Prior to version 7, two main versions of the library existed. ''Chipmunk2D Free'' was wr ...


References


External links

* {{Physics engines 2006 software Computer physics engines Software using the zlib license Software using the MIT license