npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dill-pixel/plugin-crunch-physics

v6.2.3

Published

Crunch Physics

Readme

Crunch Physics Plugin

@dill-pixel/physics-crunch

A lightweight, grid-based AABB physics plugin for Dill Pixel games. Optimized for 2D platformers and games requiring precise, pixel-perfect collisions.

Features

  • 🎯 Pixel-perfect AABB collision detection
  • 📦 Grid-based spatial partitioning for efficient collision checks
  • 🎮 Optimized for 2D platformers and action games
  • 🧩 System supports Actors (Dynamic), Solids (Static), and Sensors (Trigger - Dynamic or Static)
  • 🎨 Debug visualization tools
  • 🔄 Object pooling support
  • 🎬 Scene-based integration

Installation

npm install @dill-pixel/physics-crunch

Quick Start

// in dill-pixel.config.ts
defineConfig({
  //... other config
  plugins: ['crunch-physics', { autoLoad: false }],
});

// in your scene file
import { Scene } from 'dill-pixel';

// exports
export const plugins = ['crunch-physics']; // loads the plugin for your scene

// in your scene class
export default class MyCrunchScene extends Scene {
  get physics() {
    return this.app.getPlugin('crunch-physics') as ICrunchPhysicsPlugin;
  }

  async initialize() {
    await this.physics.initialize({
      gridSize: 32,
      gravity: 980,
      maxVelocity: 1000,
      debug: true,
    });

    // Create a player
    const player = physics.createActor({
      type: 'Player',
      position: [100, 100],
      size: [32, 64],
    });

    // Create a platform
    const platform = physics.createSolid({
      type: 'Platform',
      position: [0, 500],
      size: [800, 32],
    });

    // Create a coin pickup
    const coin = physics.createSensor({
      type: 'Coin',
      position: [200, 400],
      size: [32, 32],
    });
  }
}

Core Components

Actors

Dynamic entities that can move and collide (players, enemies, projectiles).

class Player extends Actor {
  update(dt: number) {
    // Custom movement logic
    if (this.app.input.isKeyDown('ArrowRight')) {
      this.velocity.x = 200;
    }
  }

  onCollide(result: CollisionResult) {
    // Handle collisions
    if (result.solid.type === 'Spikes') {
      this.die();
    }
  }
}

Solids

Static or moving collision objects (platforms, walls, obstacles).

// Create a moving platform
const platform = physics.createSolid({
  type: 'Platform',
  position: [100, 300],
  size: [200, 32],
});

// Animate platform movement
gsap.to(platform, {
  x: 500,
  duration: 2,
  yoyo: true,
  repeat: -1,
});

Sensors

Trigger zones for detecting overlaps (collectibles, checkpoints, damage zones).

class Coin extends Sensor {
  onActorEnter(actor: Actor) {
    if (actor.type === 'Player') {
      increaseScore(10);
      this.physics.removeSensor(this);
    }
  }
}

Groups

Containers for managing collections of entities that move together.

// Create a moving platform with hazards
const group = physics.createGroup({
  type: 'MovingPlatform',
  position: [100, 300],
});

const platform = physics.createSolid({
  type: 'Platform',
  size: [200, 32],
});

const spikes = physics.createSensor({
  type: 'Spikes',
  position: [0, -32],
  size: [200, 32],
});

group.add(platform);
group.add(spikes);

Advanced Features

Spatial Partitioning

The plugin uses a grid-based spatial partitioning system to efficiently handle collision detection:

// Configure grid size for your game's scale
physics.system.gridSize = 32;

Debug Visualization

Enable debug rendering to visualize collision boxes and the spatial grid:

physics.system.debug = true;

Collision Resolution

Custom collision handling with type-based filtering:

physics.system.setCollisionResolver((collisions) => {
  for (const collision of collisions) {
    // Handle specific collision types
    if (collision.type === 'Player|Enemy') {
      handlePlayerEnemyCollision(collision);
    }
  }
});

Performance Tips

  • Use appropriate grid sizes for your game's scale
  • Enable culling for large levels
  • Utilize object pooling for frequently created/destroyed entities
  • Use sensor overlaps instead of continuous collision checks where possible

License

MIT © Dill Pixel