Fixed deltatime
This commit is contained in:
@@ -267,7 +267,7 @@
|
||||
|
||||
function builtinRead(x) {
|
||||
if (x === 'screen' || x === './screen.js') {
|
||||
const url = new URL('screen.js', window.location.href).href;
|
||||
const url = new URL('screen.js?t=' + Date.now(), window.location.href).href;
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", url, false);
|
||||
xhr.send();
|
||||
|
||||
18
screen.js
18
screen.js
@@ -128,9 +128,12 @@ var $builtinmodule = function (name) {
|
||||
return Sk.builtin.none.none$;
|
||||
});
|
||||
|
||||
var current_dt = 0;
|
||||
|
||||
function makeSafePyCallbackNoArgs(pyFunc) {
|
||||
if (!pyFunc || pyFunc === Sk.builtin.none.none$) return null;
|
||||
return function () {
|
||||
return function (dt) {
|
||||
if (typeof dt === 'number') current_dt = dt;
|
||||
try { return Sk.misceval.callsimArray(pyFunc, []); }
|
||||
catch (e) {
|
||||
if (window.outf) window.outf(`[Error] ${e}\n`);
|
||||
@@ -142,7 +145,10 @@ var $builtinmodule = function (name) {
|
||||
|
||||
function makePyCallbackNoArgs(pyFunc) {
|
||||
if (!pyFunc || pyFunc === Sk.builtin.none.none$) return null;
|
||||
return function () { return Sk.misceval.callsimArray(pyFunc, []); };
|
||||
return function (dt) {
|
||||
if (typeof dt === 'number') current_dt = dt;
|
||||
return Sk.misceval.callsimArray(pyFunc, []);
|
||||
};
|
||||
}
|
||||
|
||||
function makePyCallbackTapArgs(pyFunc) {
|
||||
@@ -162,10 +168,16 @@ var $builtinmodule = function (name) {
|
||||
};
|
||||
}
|
||||
|
||||
console.log("LiteCanvas Screen Module Loaded (v1.2)");
|
||||
Object.defineProperty(mod, 'T', { get: function () { return toPy(lc_instance ? lc_instance.T : (window.T || 0)); } });
|
||||
Object.defineProperty(mod, 'W', { get: function () { return toPy(lc_instance ? lc_instance.W : (window.W || 0)); } });
|
||||
Object.defineProperty(mod, 'H', { get: function () { return toPy(lc_instance ? lc_instance.H : (window.H || 0)); } });
|
||||
Object.defineProperty(mod, 'DT', { get: function () { return toPy(lc_instance ? lc_instance.dt : (window.dt || 0)); } });
|
||||
Object.defineProperty(mod, 'DT', {
|
||||
get: function () {
|
||||
if (lc_instance && lc_instance.dt !== undefined) return toPy(lc_instance.dt);
|
||||
return toPy(current_dt);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(mod, 'MX', {
|
||||
get: function () {
|
||||
let mx = lc_instance ? lc_instance.MX : (window.MX || -1);
|
||||
|
||||
Reference in New Issue
Block a user