ld55 fixes
This commit is contained in:
parent
c05cb3c6d2
commit
7e04937c8b
2
Makefile
2
Makefile
|
@ -101,7 +101,7 @@ ifeq ($(OS), Windows_NT) # then WINDOWS
|
||||||
LDFLAGS += -mwin32 -static
|
LDFLAGS += -mwin32 -static
|
||||||
CPPFLAGS += -mwin32
|
CPPFLAGS += -mwin32
|
||||||
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m pthread
|
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m pthread
|
||||||
EXT = .exe
|
|
||||||
PKGCMD = zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
PKGCMD = zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
||||||
ZIP = .zip
|
ZIP = .zip
|
||||||
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
||||||
|
|
|
@ -71,6 +71,7 @@ actor.delay = function(fn, seconds) {
|
||||||
|
|
||||||
stop.remain = seconds;
|
stop.remain = seconds;
|
||||||
stop.seconds = seconds;
|
stop.seconds = seconds;
|
||||||
|
stop.pct = function() { return 1-(stop.remain / stop.seconds); };
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
stop.remain -= dt;
|
stop.remain -= dt;
|
||||||
|
|
|
@ -898,14 +898,12 @@ Object.defineProperty(Array.prototype, 'copy', {
|
||||||
|
|
||||||
Object.defineProperty(Array.prototype, 'dofilter', {
|
Object.defineProperty(Array.prototype, 'dofilter', {
|
||||||
value: function(fn) {
|
value: function(fn) {
|
||||||
var j = 0;
|
for (let i = 0; i < this.length; i++) {
|
||||||
this.forEach(function(val,i) {
|
if (!fn.call(this, this[i], i, this)) {
|
||||||
if (fn(val)) {
|
this.splice(i, 1);
|
||||||
if (i !== j) this[j] = val;
|
i--;
|
||||||
j++;
|
}
|
||||||
}
|
}
|
||||||
}, this);
|
|
||||||
this.length = j;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1095,13 +1093,19 @@ Object.defineProperty(Array.prototype, 'scale', {
|
||||||
return this.map(function(x) { return x*s; });
|
return this.map(function(x) { return x*s; });
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
Object.defineProperty(Array.prototype, 'sorted', {
|
||||||
|
value: function() {
|
||||||
|
return this.toSorted();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Object.defineProperty(Array.prototype, 'equal', {
|
Object.defineProperty(Array.prototype, 'equal', {
|
||||||
value: function(b) {
|
value: function(b) {
|
||||||
if (this.length !== b.length) return false;
|
if (this.length !== b.length) return false;
|
||||||
if (b == null) return false;
|
if (b == null) return false;
|
||||||
if (this === b) return true;
|
if (this === b) return true;
|
||||||
|
|
||||||
return JSON.stringify(this.sort()) === JSON.stringify(b.sort());
|
return JSON.stringify(this.sorted()) === JSON.stringify(b.sorted());
|
||||||
|
|
||||||
for (var i = 0; i < this.length; i++) {
|
for (var i = 0; i < this.length; i++) {
|
||||||
if (!this[i] === b[i])
|
if (!this[i] === b[i])
|
||||||
|
|
|
@ -234,7 +234,7 @@ Object.seal(sprite);
|
||||||
var animcache = {};
|
var animcache = {};
|
||||||
var SpriteAnim = {};
|
var SpriteAnim = {};
|
||||||
SpriteAnim.make = function(path) {
|
SpriteAnim.make = function(path) {
|
||||||
if (animcache[path]) return animcache[path];
|
if (path in animcache) return animcache[path];
|
||||||
var anim;
|
var anim;
|
||||||
if (io.exists(path.set_ext(".ase")))
|
if (io.exists(path.set_ext(".ase")))
|
||||||
anim = SpriteAnim.aseprite(path.set_ext(".ase"));
|
anim = SpriteAnim.aseprite(path.set_ext(".ase"));
|
||||||
|
@ -245,7 +245,7 @@ SpriteAnim.make = function(path) {
|
||||||
else if (path.ext() === 'gif')
|
else if (path.ext() === 'gif')
|
||||||
anim = SpriteAnim.gif(path);
|
anim = SpriteAnim.gif(path);
|
||||||
else
|
else
|
||||||
return undefined;
|
anim = undefined;
|
||||||
|
|
||||||
animcache[path] = anim;
|
animcache[path] = anim;
|
||||||
return animcache[path];
|
return animcache[path];
|
||||||
|
|
|
@ -119,6 +119,27 @@ qq = 'ms';
|
||||||
return `${t.toPrecision(4)} ${qq}`;
|
return `${t.toPrecision(4)} ${qq}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile.report = function(start, msg = "[undefined report]")
|
||||||
|
{
|
||||||
|
console.info(`${msg} in ${profile.best_t(profile.now()-start)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addreport = function(cache, line, start)
|
||||||
|
{
|
||||||
|
cache[line] ??= [];
|
||||||
|
cache[line].push(profile.now()-start);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.printreport = function(cache, name)
|
||||||
|
{
|
||||||
|
var report = name + "\n";
|
||||||
|
for (var i in cache) {
|
||||||
|
report += `${i} ${profile.best_t(profcache[i].reduce((a,b) => a+b)/profcache[i].length)}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
console.transcript = "";
|
console.transcript = "";
|
||||||
console.say = function(msg) {
|
console.say = function(msg) {
|
||||||
msg += "\n";
|
msg += "\n";
|
||||||
|
@ -181,14 +202,19 @@ console.doc = {
|
||||||
|
|
||||||
globalThis.global = globalThis;
|
globalThis.global = globalThis;
|
||||||
|
|
||||||
|
var profcache = {};
|
||||||
|
|
||||||
function use(file, env = {}, script)
|
function use(file, env = {}, script)
|
||||||
{
|
{
|
||||||
file = Resources.find_script(file);
|
file = Resources.find_script(file);
|
||||||
var st = profile.now();
|
var st = profile.now();
|
||||||
|
|
||||||
|
profcache[file] ??= [];
|
||||||
|
|
||||||
if (use.cache[file]) {
|
if (use.cache[file]) {
|
||||||
var ret = use.cache[file].call(env);
|
var ret = use.cache[file].call(env);
|
||||||
console.info(`CACHE eval ${file} in ${profile.best_t(profile.now()-st)}`);
|
profile.report(st, `CACHE eval ${file}`);
|
||||||
|
profile.addreport(profcache, file, st);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.info(`slurping ${file}`);
|
console.info(`slurping ${file}`);
|
||||||
|
@ -197,7 +223,8 @@ function use(file, env = {}, script)
|
||||||
var fn = os.eval(file,script);
|
var fn = os.eval(file,script);
|
||||||
use.cache[file] = fn;
|
use.cache[file] = fn;
|
||||||
var ret = fn.call(env);
|
var ret = fn.call(env);
|
||||||
console.info(`eval ${file} in ${profile.best_t(profile.now()-st)}`);
|
profile.report(st, `eval ${file}`);
|
||||||
|
profile.addreport(profcache, file, st);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +456,10 @@ prosperon.touchrelease = function(touches){};
|
||||||
prosperon.touchmove = function(touches){};
|
prosperon.touchmove = function(touches){};
|
||||||
prosperon.clipboardpaste = function(str){};
|
prosperon.clipboardpaste = function(str){};
|
||||||
prosperon.quit = function(){
|
prosperon.quit = function(){
|
||||||
|
console.info(profile.printreport(profcache, "USE REPORT"));
|
||||||
|
console.info(profile.printreport(entityreport, "ENTITY REPORT"));
|
||||||
|
|
||||||
|
console.info("QUITTING");
|
||||||
for (var i in debug.log.time)
|
for (var i in debug.log.time)
|
||||||
console.warn(debug.log.time[i].map(x=>profile.ms(x)));
|
console.warn(debug.log.time[i].map(x=>profile.ms(x)));
|
||||||
};
|
};
|
||||||
|
@ -567,6 +598,8 @@ function world_start() {
|
||||||
world.phys = 2;
|
world.phys = 2;
|
||||||
world.zoom = 1;
|
world.zoom = 1;
|
||||||
world._ed = { selectable: false };
|
world._ed = { selectable: false };
|
||||||
|
world.ur = {};
|
||||||
|
world.ur.fresh = {};
|
||||||
game.cam = world;
|
game.cam = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
globalThis.entityreport = {};
|
||||||
|
|
||||||
function obj_unique_name(name, obj) {
|
function obj_unique_name(name, obj) {
|
||||||
name = name.replaceAll('.', '_');
|
name = name.replaceAll('.', '_');
|
||||||
if (!(name in obj)) return name;
|
if (!(name in obj)) return name;
|
||||||
|
@ -129,6 +131,7 @@ var gameobject = {
|
||||||
|
|
||||||
stop.remain = seconds;
|
stop.remain = seconds;
|
||||||
stop.seconds = seconds;
|
stop.seconds = seconds;
|
||||||
|
stop.pct = function() { return 1 - (stop.remain/stop.seconds); };
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
stop.remain -= dt;
|
stop.remain -= dt;
|
||||||
|
@ -140,9 +143,7 @@ var gameobject = {
|
||||||
return stop;
|
return stop;
|
||||||
},
|
},
|
||||||
|
|
||||||
cry(file) {
|
cry(file) { return audio.cry(file); },
|
||||||
return audio.cry(file);
|
|
||||||
},
|
|
||||||
|
|
||||||
set pos(x) { this.set_pos(x); },
|
set pos(x) { this.set_pos(x); },
|
||||||
get pos() { return this.rpos; },
|
get pos() { return this.rpos; },
|
||||||
|
@ -215,6 +216,7 @@ var gameobject = {
|
||||||
nothing
|
nothing
|
||||||
*/
|
*/
|
||||||
spawn(text, config, callback) {
|
spawn(text, config, callback) {
|
||||||
|
var st = profile.now();
|
||||||
var ent = os.make_gameobject();
|
var ent = os.make_gameobject();
|
||||||
ent.guid = prosperon.guid();
|
ent.guid = prosperon.guid();
|
||||||
ent.components = {};
|
ent.components = {};
|
||||||
|
@ -327,13 +329,14 @@ var gameobject = {
|
||||||
for (var i in ent.objects)
|
for (var i in ent.objects)
|
||||||
ent.ur.fresh.objects[i] = ent.objects[i].instance_obj();
|
ent.ur.fresh.objects[i] = ent.objects[i].instance_obj();
|
||||||
|
|
||||||
|
profile.addreport(entityreport, ent.ur.name, st);
|
||||||
return ent;
|
return ent;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Reparent 'this' to be 'parent's child */
|
/* Reparent 'this' to be 'parent's child */
|
||||||
reparent(parent) {
|
reparent(parent) {
|
||||||
assert(parent, `Tried to reparent ${this.toString()} to nothing.`);
|
assert(parent, `Tried to reparent ${this.toString()} to nothing.`);
|
||||||
console.info(`parenting ${this.toString()} to ${parent.toString()}`);
|
console.spam(`parenting ${this.toString()} to ${parent.toString()}`);
|
||||||
if (this.master === parent) {
|
if (this.master === parent) {
|
||||||
console.warn("not reparenting ...");
|
console.warn("not reparenting ...");
|
||||||
console.warn(`${this.master} is the same as ${parent}`);
|
console.warn(`${this.master} is the same as ${parent}`);
|
||||||
|
@ -731,7 +734,7 @@ game.loadurs = function() {
|
||||||
Object.assign(newur, urjson);
|
Object.assign(newur, urjson);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var file of io.glob("**.jso")) {
|
for (var file of io.glob("**.jso").filter(f => !ur[f.name()])) {
|
||||||
if (file[0] === '.' || file[0] === '_') continue;
|
if (file[0] === '.' || file[0] === '_') continue;
|
||||||
var newur = ur_from_file(file);
|
var newur = ur_from_file(file);
|
||||||
if (!newur) continue;
|
if (!newur) continue;
|
||||||
|
@ -744,7 +747,7 @@ game.loadurs = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var file of io.glob("**.json")) {
|
for (var file of io.glob("**.json").filter(f => !ur[f.name()])) {
|
||||||
if (file[0] === '.' || file[0] === '_') continue;
|
if (file[0] === '.' || file[0] === '_') continue;
|
||||||
var newur = ur_from_file(file);
|
var newur = ur_from_file(file);
|
||||||
if (!newur) continue;
|
if (!newur) continue;
|
||||||
|
|
|
@ -36,6 +36,8 @@ pressrep
|
||||||
down
|
down
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function keycode(name) { return charCodeAt(name); }
|
||||||
|
|
||||||
function keyname_extd(key)
|
function keyname_extd(key)
|
||||||
{
|
{
|
||||||
if (key > 289 && key < 302) {
|
if (key > 289 && key < 302) {
|
||||||
|
@ -67,7 +69,7 @@ function modstr()
|
||||||
|
|
||||||
prosperon.keydown = function(key, repeat)
|
prosperon.keydown = function(key, repeat)
|
||||||
{
|
{
|
||||||
prosperon.keys[key] = key;
|
prosperon.keys[key] = true;
|
||||||
|
|
||||||
if (key == 341 || key == 345)
|
if (key == 341 || key == 345)
|
||||||
mod.ctrl = 1;
|
mod.ctrl = 1;
|
||||||
|
@ -179,7 +181,7 @@ input.mouse.normal.doc = "Set the mouse to show again after hiding.";
|
||||||
input.keyboard = {};
|
input.keyboard = {};
|
||||||
input.keyboard.down = function(code) {
|
input.keyboard.down = function(code) {
|
||||||
if (typeof code === 'number') return prosperon.keys[code];
|
if (typeof code === 'number') return prosperon.keys[code];
|
||||||
if (typeof code === 'string') return prosperon.keys[keyname_extd(code)];
|
if (typeof code === 'string') return (prosperon.keys[code.uc().charCodeAt()] || prosperon.keys[code.lc().charCodeAt()]);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ audio.dsp = dspsound;
|
||||||
audio.cry = function(file)
|
audio.cry = function(file)
|
||||||
{
|
{
|
||||||
var player = audio.play(file);
|
var player = audio.play(file);
|
||||||
|
if (!player) return;
|
||||||
|
|
||||||
player.guid = prosperon.guid();
|
player.guid = prosperon.guid();
|
||||||
cries[player.guid] = player;
|
cries[player.guid] = player;
|
||||||
player.ended = function() { delete cries[player.guid]; player = undefined; }
|
player.ended = function() { delete cries[player.guid]; player = undefined; }
|
||||||
|
@ -46,15 +48,19 @@ var song;
|
||||||
audio.music = function(file, fade = 0) {
|
audio.music = function(file, fade = 0) {
|
||||||
if (!fade) {
|
if (!fade) {
|
||||||
song = audio.play(file);
|
song = audio.play(file);
|
||||||
|
song.loop = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var temp = audio.play(file);
|
var temp = audio.play(file);
|
||||||
|
if (!temp) return;
|
||||||
|
|
||||||
temp.volume = 0;
|
temp.volume = 0;
|
||||||
var temp2 = song;
|
var temp2 = song;
|
||||||
tween(temp, 'volume', 1, fade);
|
tween(temp, 'volume', 1, fade);
|
||||||
tween(temp2, 'volume', 0, fade);
|
tween(temp2, 'volume', 0, fade);
|
||||||
song = temp;
|
song = temp;
|
||||||
|
song.loop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio.dsp.mix = function(to) {
|
audio.dsp.mix = function(to) {
|
||||||
|
|
|
@ -191,7 +191,6 @@ Cmdline.register_order("edit", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.size = [1280, 720];
|
window.size = [1280, 720];
|
||||||
|
|
||||||
window.mode = window.modetypes.full;
|
window.mode = window.modetypes.full;
|
||||||
sim.pause();
|
sim.pause();
|
||||||
|
|
||||||
|
@ -249,9 +248,9 @@ Cmdline.register_order("play", function(argv) {
|
||||||
console.info(`Starting game with window size ${window.size} and render ${window.rendersize}.`);
|
console.info(`Starting game with window size ${window.size} and render ${window.rendersize}.`);
|
||||||
|
|
||||||
game.engine_start(function() {
|
game.engine_start(function() {
|
||||||
|
render.set_font("fonts/c64.ttf", 8);
|
||||||
global.app = actor.spawn("game.js");
|
global.app = actor.spawn("game.js");
|
||||||
if (project.icon) window.set_icon(game.texture(project.icon));
|
if (project.icon) window.set_icon(game.texture(project.icon));
|
||||||
render.set_font("fonts/c64.ttf", 8);
|
|
||||||
game.camera = world.spawn("scripts/camera2d");
|
game.camera = world.spawn("scripts/camera2d");
|
||||||
});
|
});
|
||||||
}, "Play the game present in this folder.");
|
}, "Play the game present in this folder.");
|
||||||
|
|
|
@ -120,7 +120,7 @@ var tween = function(obj, val, to, time)
|
||||||
|
|
||||||
var Tween = {
|
var Tween = {
|
||||||
default: {
|
default: {
|
||||||
loop: "restart",
|
loop: "hold",
|
||||||
/*
|
/*
|
||||||
loop types
|
loop types
|
||||||
none: when done, return to first value
|
none: when done, return to first value
|
||||||
|
|
|
@ -200,6 +200,7 @@ static sapp_desc start_desc = {
|
||||||
.cleanup_cb = c_clean,
|
.cleanup_cb = c_clean,
|
||||||
.event_cb = c_event,
|
.event_cb = c_event,
|
||||||
.logger.func = sg_logging,
|
.logger.func = sg_logging,
|
||||||
|
.win32_console_create = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
sapp_desc sokol_main(int argc, char **argv) {
|
sapp_desc sokol_main(int argc, char **argv) {
|
||||||
|
|
Loading…
Reference in a new issue