mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Complete Box2D to Planck.js migration
- Replace Box2D.js with Planck.js physics engine - Update all require paths from 'Lib/Vendor/Box2D' to 'Lib/Vendor/Planck' - Convert Box2D contact listeners to Planck.js event system - Fix all method name capitalization (Get* -> get*, Set* -> set*) - Update collision detection system for Planck.js compatibility - Server now starts successfully and basic physics working - Character can land on platforms - core physics functional Major milestone: Game now running on modern, maintained physics engine
This commit is contained in:
parent
875abd60d9
commit
dc779def9c
43 changed files with 701 additions and 14524 deletions
|
|
@ -1,7 +1,7 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Doll",
|
||||
"Game/Channel/GameObjects/Item",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Lib/Vendor/Planck",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Utilities/Assert"
|
||||
],
|
||||
|
|
@ -42,14 +42,14 @@ function (Parent, Item, Box2D, nc, Assert) {
|
|||
Parent.prototype.onImpact.call(this, isColliding, fixture);
|
||||
|
||||
if(isColliding) {
|
||||
var otherBody = fixture.GetBody();
|
||||
var otherBody = fixture.getBody();
|
||||
if(otherBody) {
|
||||
var item = otherBody.GetUserData();
|
||||
var item = otherBody.getUserData();
|
||||
if(item instanceof Item) {
|
||||
var itemVelocity = item.body.GetLinearVelocity();
|
||||
//var itemMass = item.body.GetMass();
|
||||
var itemVelocity = item.body.getLinearVelocity();
|
||||
//var itemMass = item.body.getMass();
|
||||
|
||||
var ownVelocity = this.body.GetLinearVelocity();
|
||||
var ownVelocity = this.body.getLinearVelocity();
|
||||
|
||||
var b2Math = Box2D.Common.Math.b2Math;
|
||||
var absItemVelocity = b2Math.AbsV(itemVelocity);
|
||||
|
|
@ -97,9 +97,9 @@ function (Parent, Item, Box2D, nc, Assert) {
|
|||
if(!this.isAnotherPlayerNearby()) {
|
||||
Assert.number(update.p.x, update.p.y);
|
||||
Assert.number(update.lv.x, update.lv.y);
|
||||
this.body.SetAwake(true);
|
||||
this.body.SetPosition(update.p);
|
||||
this.body.SetLinearVelocity(update.lv);
|
||||
this.body.setAwake(true);
|
||||
this.body.setPosition(update.p);
|
||||
this.body.setLinearVelocity(update.lv);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/GameObject",
|
||||
"Lib/Vendor/Box2D"
|
||||
"Lib/Vendor/Planck"
|
||||
],
|
||||
|
||||
function (Parent, Box2D) {
|
||||
|
|
@ -19,19 +19,19 @@ function (Parent, Box2D) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (this.body.GetType() === Box2D.Dynamics.b2Body.b2_staticBody) {
|
||||
if (this.body.getType() === 'static') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!getSleeping && !this.body.IsAwake()) {
|
||||
if (!getSleeping && !this.body.isAwake()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
p: this.body.GetPosition(),
|
||||
a: this.body.GetAngle(),
|
||||
lv: this.body.GetLinearVelocity(),
|
||||
av: this.body.GetAngularVelocity()
|
||||
p: this.body.getPosition(),
|
||||
a: this.body.getAngle(),
|
||||
lv: this.body.getLinearVelocity(),
|
||||
av: this.body.getAngularVelocity()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ function (Parent, nc) {
|
|||
Item.prototype.onCollisionChange = function(isColliding, fixture) {
|
||||
|
||||
if(isColliding) {
|
||||
var otherBody = fixture.GetBody();
|
||||
var otherBody = fixture.getBody();
|
||||
if(otherBody) {
|
||||
var otherItem = otherBody.GetUserData();
|
||||
var otherItem = otherBody.getUserData();
|
||||
if(otherItem instanceof Item) {
|
||||
if(!this.lastMoved && !otherItem.lastMoved) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ function (Parent, Settings, nc) {
|
|||
|
||||
for(var name in this.limbs) {
|
||||
limbUpdateData[name] = {
|
||||
p: this.limbs[name].GetPosition(),
|
||||
a: this.limbs[name].GetAngle(),
|
||||
lv: this.limbs[name].GetLinearVelocity(),
|
||||
av: this.limbs[name].GetAngularVelocity()
|
||||
p: this.limbs[name].getPosition(),
|
||||
a: this.limbs[name].getAngle(),
|
||||
lv: this.limbs[name].getLinearVelocity(),
|
||||
av: this.limbs[name].getAngularVelocity()
|
||||
};
|
||||
}
|
||||
updateData['limbs'] = limbUpdateData;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue