Catalog npm
PACKAGE EXPLORERView in registry

2d-bounding-box

npm

A simple 2d bounding box class. Intersections collisions, for use in 2d games

2daabbbbboundingbox
Versions collected1
Direct dependencies17From release 0.0.1
Last observed20 Oct, 19:10 UTC

README

Current package documentation

simple 2d bounding box library

Note, this is still in alpha and may contain lots and lots of bugs. Please make an issue if you encounter a bug.

To use it:

let BoundingBox = require('2d-bounding-box');

let bb_create = new BoundingBox( min_x, min_y, max_x, max_y, [origin_type]);

Sometimes you already have an entity with a certain width and height, and you wish to create a bounding box based on the dimensions of this creature without having to calculate the correct positions yourself.

Important is for these calculations that you define where the origin of your entity is. Is it smack in the middle of the entity that decides the position or anywhere around the entity, bottom left for example.

let bb_from_entity = BoundingBox.create( origin_type, position_x, position_y, width, height);

For the origin type there are 9 possible options:

BoundingBox.ORIGIN_CENTER;
BoundingBox.ORIGIN_LEFT_BOTTOM;
BoundingBox.ORIGIN_RIGHT_BOTTOM;
BoundingBox.ORIGIN_CENTER_BOTTOM;
BoundingBox.ORIGIN_LEFT_CENTER;
BoundingBox.ORIGIN_LEFT_TOP;
BoundingBox.ORIGIN_CENTER_TOP;
BoundingBox.ORIGIN_RIGHT_TOP;
BoundingBox.ORIGIN_RIGHT_CENTER;

If you need more options, you will have to calculate the offsets yourself and instantiate the bounding box via the new BoundingBox(...) method.

Please see the demo_basic_bb.html file in the demo directory for examples.

If you wish to fiddle with the demo_basic.js file recompile it with gulp less browserify before refreshing the demo_basic_bb.html file.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.1Registry latest26 Mar 202017

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
tschallacka/npm-2d-bounding-box

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:10 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:e54086a978747781e442fa0d5d11bf518096701468279dd4ba0a457469c15fd7