mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
- 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
68 lines
No EOL
1.7 KiB
JavaScript
Executable file
68 lines
No EOL
1.7 KiB
JavaScript
Executable file
define([
|
|
"Game/Core/Physics/Engine",
|
|
"Game/Config/Settings",
|
|
"Game/Client/View/DomController",
|
|
"Lib/Vendor/Planck",
|
|
"Lib/Utilities/NotificationCenter",
|
|
"Game/Client/View/Pixi/PlanckDebugDraw",
|
|
"Game/Client/View/Pixi/Layers/Debug"
|
|
],
|
|
|
|
function (Parent, Settings, domController, Box2D, nc, PlanckDebugDraw, debugLayer) {
|
|
|
|
"use strict";
|
|
|
|
function Engine () {
|
|
Parent.call(this);
|
|
|
|
this.debugMode = false;
|
|
|
|
nc.on(nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this);
|
|
}
|
|
|
|
Engine.prototype = Object.create(Parent.prototype);
|
|
|
|
Engine.prototype.onToggleDebugMode = function(debugMode) {
|
|
this.debugMode = debugMode;
|
|
|
|
if(!this.debugDraw) {
|
|
this.setupDebugDraw();
|
|
}
|
|
|
|
debugLayer.container.visible = this.debugMode;
|
|
};
|
|
|
|
Engine.prototype.setupDebugDraw = function () {
|
|
|
|
// set debug draw for Planck.js
|
|
var canvas = document.createElement('canvas');
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
canvas.style.position = 'absolute';
|
|
canvas.style.top = '0';
|
|
canvas.style.left = '0';
|
|
canvas.style.pointerEvents = 'none';
|
|
canvas.style.zIndex = '1000';
|
|
document.body.appendChild(canvas);
|
|
|
|
this.debugDraw = new PlanckDebugDraw(canvas);
|
|
this.debugCanvas = canvas;
|
|
};
|
|
|
|
Engine.prototype.renderDebug = function () {
|
|
if (this.debugDraw) {
|
|
this.debugDraw.clear();
|
|
this.debugDraw.drawWorld(this.world);
|
|
}
|
|
};
|
|
|
|
Engine.prototype.update = function () {
|
|
Parent.prototype.update.call(this);
|
|
|
|
if(this.debugMode) {
|
|
this.world.DrawDebugData();
|
|
}
|
|
};
|
|
|
|
return Engine;
|
|
}); |