Giter Club home page Giter Club logo

matter-wrap's Introduction

matter-wrap

A coordinate wrapping plugin for matter.js

Build Status

This plugin allows you to automatically wrap the position of bodies and composites such that they always stay within the given bounds. Upon crossing a boundary the body will appear on the opposite side of the bounds, while maintaining its velocity. An example of this effect can be seen in the classic Asteroids and Pacman games.

Demo

See the demo.

matter-wrap

Install

Get the matter-wrap.js file directly or get it via npm:

npm install matter-wrap

Dependencies

Usage

Matter.use('matter-wrap');
// or
Matter.use(MatterWrap);

See Using Plugins for more information.

An example of a body that wraps between the bounds (0, 0) and (1024, 1024). For wrapping composites set composite.plugin.wrap as below.

var body = Matter.Bodies.circle(0, 0, 10, {
  plugin: {
    wrap: {
      min: {
        x: 0,
        y: 0
      },
      max: {
        x: 1024,
        y: 1024
      }
    }
  }
);

Examples

Check out the examples.

Documentation

See the API docs.

matter-wrap's People

Contributors

liabru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

matter-wrap's Issues

Wrong versions

Current version of plugin is 0.2.0, but in code, is stil:

version: '0.1.3', // PLUGIN_VERSION
for: 'matter-js@^0.12.0',

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.