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

@tastic/physics

v0.2.0

Published

2D arcade-game physics: circle/rect/rounded-rect collision and reflection, friction, gravity wells, springs, and velocity clamping — built on @tastic/core's Vec2

Readme

@tastic/physics

2D arcade-game physics: collision detection and resolution, friction, gravity, springs, and velocity clamping. Pure, framework-agnostic functions built on @tastic/core's Vec2 — no React or React Native dependency, callable equally from a plain JS reducer (a requestAnimationFrame-driven game loop) or from inside a Reanimated worklet.

What it does

Narrow-phase collision detection (circleVsRect, circleVsCircle) — does a moving circle overlap a solid rectangle or circle, and if so, by how much and in which direction? Returns a unit normal (outward from the solid) and depth (how far to push the circle out to resolve the overlap).

Collision response:

  • reflectOffNormal(velocity, normal, restitution) — bounce a velocity off a surface normal.
  • resolveCircleCollision(a, b, minDistance, restitution) — a full two-body elastic/inelastic circle collision: pushes overlapping circles apart and exchanges the normal component of their velocities, conserving momentum exactly (and kinetic energy too, at restitution 1).

Boundary containment:

  • reflectCircleInRoundedRect(position, velocity, radius, bounds, cornerRadius, restitution) — keeps a circle contained within a rounded-rectangle boundary, bouncing it off whichever edge or corner it crosses. One function covers a puck bouncing off a rink wall (radius > 0, rounded corners), a ball in a rectangular play field (radius > 0, square corners), or a drag point contained within a rounded screen edge (radius 0) — no need for a separate function per shape.

Forces:

  • applyFriction(velocity, retentionPerFrame, dt) — exponential drag, frame-rate independent.
  • applyGravityWells(position, velocity, wells, dt, options) — a bounded, quadratic-falloff-to-zero attractor/repeller field, for one or more localized "wells" an object can enter and be pulled or pushed by.
  • applyGravityPull(position, velocity, center, gravity, dt) — an unbounded linear pull toward a single always-on center. A different model from the wells above (grows with distance instead of falling off, no radius) — pick whichever shape matches what you're building.
  • applySpringForce(position, velocity, target, stiffness, damping, dt) — a damped spring pull toward a point. Use damping = 2*sqrt(stiffness) for critical damping (settles without overshoot).
  • clampSpeed(velocity, maxSpeed) — caps a velocity's magnitude without changing its direction.

Install (local dev via yalc)

Not published to the public npm registry yet.

cd game-physics
npm run build
yalc publish

cd ../your-game
yalc add @tastic/physics
npm install

Peer dependencies

@tastic/core (>=0.1.0) — required for the Vec2 type every function here operates on.