Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding another shape

  • Loading branch information...
commit 8af385becd7182d1535006b1ab8437b96ab52a09 1 parent daf304a
@gregschlom authored
Showing with 13 additions and 7 deletions.
  1. +13 −7 index2.html
View
20 index2.html
@@ -86,8 +86,8 @@
<script>
// Create world
var worldAABB = new b2AABB();
- worldAABB.minVertex.Set(0, 0);
- worldAABB.maxVertex.Set(1000, 500);
+ worldAABB.minVertex.Set(-1000, -1000);
+ worldAABB.maxVertex.Set(2000, 2000);
var gravity = new b2Vec2(0, 300);
var world = new b2World(worldAABB, gravity, true); // true is for allowSleep
@@ -101,7 +101,7 @@
// Create the motorbike
var rearWheel = new b2CircleDef();
rearWheel.density = 1.0;
- rearWheel.restitution = 1.0;
+ rearWheel.restitution = 0.2;
rearWheel.friction = 0;
rearWheel.localPosition.x = 0;
rearWheel.localPosition.y = 0;
@@ -109,7 +109,7 @@
var frontWheel = new b2CircleDef();
frontWheel.density = 1.0;
- frontWheel.restitution = 1.0;
+ frontWheel.restitution = 0.2;
frontWheel.friction = 0;
frontWheel.localPosition.x = 80;
frontWheel.localPosition.y = -10;
@@ -129,7 +129,7 @@
bikeBd.AddShape(frontWheel);
bikeBd.AddShape(rearWheel);
bikeBd.AddShape(frame);
- bikeBd.position.Set(100, 30);
+ bikeBd.position.Set(50, 300);
bike = world.CreateBody(bikeBd);
@@ -149,9 +149,15 @@
var groundBd1 = new b2BodyDef();
groundBd1.AddShape(groundSd1);
groundBd1.position.Set(100, 500);
- return world.CreateBody(groundBd1);
+ world.CreateBody(groundBd1);
-
+ var groundSd2 = new b2BoxDef();
+ groundSd2.extents.Set(100, 10);
+ groundSd2.restitution = 0.5;
+ var groundBd2 = new b2BodyDef();
+ groundBd2.AddShape(groundSd2);
+ groundBd2.position.Set(800, 550);
+ world.CreateBody(groundBd2);
}
Please sign in to comment.
Something went wrong with that request. Please try again.