Migrate Box2D to Planck.js in core game logic, items, debug draw, and menu. Remove legacy Box2D references, update level and item loading, and improve debug draw for Planck.

This commit is contained in:
Karl Pannek 2025-07-17 18:50:16 +02:00
parent 799601f24d
commit da6e9a244b
15 changed files with 66 additions and 201 deletions

View file

@ -51,18 +51,17 @@ function (Parent, Item, Box2D, nc, Assert) {
var ownVelocity = this.body.getLinearVelocity();
var b2Math = Box2D.Common.Math.b2Math;
var absItemVelocity = b2Math.AbsV(itemVelocity);
var absItemVelocity = { x: Math.abs(itemVelocity.x), y: Math.abs(itemVelocity.y) };
var min = 1;
var damage = 0;
if(absItemVelocity.x > min || absItemVelocity.y > min) {
if(item.lastMoved && item.lastMoved.player != this.player) {
var collision = b2Math.SubtractVV(itemVelocity, ownVelocity);
var collision = planck.Vec2(itemVelocity).sub(planck.Vec2(ownVelocity));
// Tested max velocity banana: 50
var velocityDamage = collision.Length() / 50;
var velocityDamage = collision.length() / 50;
// Max weight of piano: 15
var weightDamage = item.options.weight / 15;