Crater is a fast physics simulation for handling large quantities of solid rectangular crates. It was developed primarily to be the base for grid based physics games such as platformer-games. Despite of being a physics simulation library, it does not perform any calculation regarding separation, so objects will collide but remain still after they touch each other.

The library is useful to create any game that does not rely on separation, such as a tetris clone. Its feature set is not as complex as similar physics simulation libraries, such as Nape.

Sample

var sim:Simulation;
var bitmap:Bitmap;

sim = new Simulation(new Rectangle(0, 0, WIDTH, HEIGHT), CELL_SCALE);
var r:int, c:int;
for(r = 0; r < 120; r += CRATE_SIZE){
  for(c = 0; c < WIDTH; c += CRATE_SIZE){
    sim.addCollider(c, r, CRATE_SIZE, CRATE_SIZE);
  }
}

sim.main();

// render
bitmap.bitmapData.fillRect(bitmap.bitmapData.rect, 0x00000000);
var rect:Rectangle = new Rectangle(0, 0, SCALE - 2, SCALE - 2);
for(i = 0; i < sim.colliders.length; i++){
  bitmap.bitmapData.fillRect(sim.colliders[i], 0xFFFFFFFF);
  rect.x = sim.colliders[i].x + 1;
  rect.y = sim.colliders[i].y + 1;
  bitmap.bitmapData.fillRect(rect, 0xFFCCCCCC);
}
2D. URL.