Browsing articles tagged with

box2d

Revolute joint in box2d in javascript

Revolute Joint Revolute joint is a useful joint in box2d that allows 2 bodies to be pinned together at a point without restricting rotation. Lets take an example The joint can be made between 2 dynamic bodies or between a static and dynamic body. The pendulum on left is a static circle joined to dynamic rectangle. Whereas the cart with 2 wheels ...

Weld joint in box2d in javascript

Weld joint in box2d The weld joint can be used to join to bodies tightly at a common point. Here is an example A weld joint is created like this //create distance joint between b and c var joint_def = new b2WeldJointDef(); joint_def.bodyA = b; joint_def.bodyB = c; //connect the centers - center in local coordinate - relative to body is 0,0 joint_def.localAnchorA ...

Make a rope using box2d in javascript

Rope In this experiment we shall make a rope like thing in box2d. There is no rope like structure that box2d supports directly. But if multiple small units are connected together at their edges using a revolutejoint, then it was act somewhat like a rope. Lets take a look You can move any part of the rope using your mouse. Now in this ...

Distance joint in box2d in javascript

Distance In the previous post on mouse joints we learned how to interact with box2d objects using the mouse. Now its time to take a look at another joint in box2d, the distance joint. Distance joint connects 2 bodies maintaining a fixed distance between them, its like metal wire connecting the 2 bodies, such that the wire would neither expand nor ...

Playing with the mouse joint in box2d in javascript

Mouse Joint Out of the many joints that box2d has, one is mouse joint. It is not used in physics simulations, but helps to make the physics world interactive by making a body move towards a specific point, like the mouse coordinates for example. So objects can be picked up, dragged etc by the user. Lets take an example Pickup an object by ...

Make a simple html5 game with box2d in javascript – tutorial

Demo First lets play the game that we shall be making in this tutorial. Its called Fruit Hunter. Tested on Chrome and Firefox. Click in the game then start using the arrow keys to control the monkey. Press the left, right and up arrow keys to make the monkey move and jump. Do not fall off the stands and try to ...

Programming box2d in javascript – tutorial on basics

Box2d Box2d is a 2d physics simulation library written for C++ and ported to many languages including Javascript. From Box2d's Website Box2D is a feature rich 2D rigid body physics engine, written in C++ by Erin Catto. It has been used in many games, including Crayon Physics Deluxe, winner of the 2008 Independant Game Festival Grand Prize. Box2d can is used to develop 2d ...

Make a racing car using Box2d in javascript

Racing car in box2d Box2d is a physics 2d simulation library and is used in game development. Apart from C/C++ it has ports for various languages like python, javascript etc. With the availability of the html5 canvas element and many other html5 apis, it becomes possible to write browser based games in javascript. So in this article we shall try to ...