Skip to content

danzen/zim-physics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

physics

ZIM Physics is a helper module for the ZIM JavaScript Canvas Framework that works with Box2DWeb. In ZIM TEN, we integrated physics - see https://zimjs.com/physics - so it is as easy as:

new Circle().center().addPhysics();

and the circle will drop to the ground! Usually we create a Physics object first so we can set gravity and boundaries if needed and call various methods on the physics object such as drag. See the ZIM Docs at https://zimjs.com/docs.html?item=Physics and https://zimjs.com/docs.html?item=addPhysics.

const physics = new Physics();
physics.drag(); // will make dynamic objects draggable
new Circle().center().addPhysics({bounciness:.7}); 

CDN

Usually we use ES Modules to bring in ZIM and if we want Physics then we use the code below - see the starting template at the top of the https://zimjs.com/code page. The zim_physics also imports the zim_game module (where as the NPM version does not).

import zim from "https://zimjs.org/cdn/016/zim_physics";

NPM

This repository holds the NPM package so you can install from @zimjs/physics on NPM. It includes typings and loads the Box2DWeb package as a dependency. The ZIM package must be installed to work.

import zim from "zimjs"
import { Physics } from "@zimjs/physics"

PHYSICS EXAMPLES

  • ZIM with Box2D - PHYSICS - ZIM TEN Example
  • ZIM with Box2D - GOAL - ZIM TEN Example
  • ZIM with Box2D - BEADS - ZIM TEN Example
  • ZIM with Box2D - KEEP UP - ZIM TEN Example
  • ZIM with Box2D - DRIVE - ZIM TEN Example
  • Cat Food - Physics Blobs - ZIM 014 Example
  • Fermenti - Physics Blobs - ZIM 014 Example
  • ZIM with Box2D - ZIM Bits
  • Soup with Box2D - ZIM Bits
  • Bugs - three levels - ZIM Kids
  • Falling Apple - CodePen (simple)
  • Alone Droid 2 - ZIM (complex)
  • Alone Droid - ZIM (complex)
  • Pinball Sparks - CodePen
  • Noodles Hair - CodePen
  • Anti-grav - CodePen
  • Polygon Pen - CodePen
  • Data Vis - CodePen
  • Maze - CodePen
  • SideScroller - ZIM
  • Valentines Puppets - ZIM
  • VIDEOS

    CODE IN FIVE (See https://zimjs.com/five/ for files)
  • Follow - Code in Five Minutes
  • Shoot - Code in Five Minutes
  • Angry Birds A - Code in Five Minutes
  • Angry Birds B - Code in Five Minutes
  • Angry Birds C - Code in Five Minutes
  • Angry Birds D - Code in Five Minutes
  • ZIM

    See the ZIM repository at https://github.com/danzen/zimjs for information on ZIM and open source license, etc.

    About

    No description, website, or topics provided.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published