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
|
||||
CPPFLAGS += -mwin32
|
||||
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/\*
|
||||
ZIP = .zip
|
||||
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
||||
|
|
|
@ -71,6 +71,7 @@ actor.delay = function(fn, seconds) {
|
|||
|
||||
stop.remain = seconds;
|
||||
stop.seconds = seconds;
|
||||
stop.pct = function() { return 1-(stop.remain / stop.seconds); };
|
||||
|
||||
function update(dt) {
|
||||
stop.remain -= dt;
|
||||
|
|
|
@ -898,14 +898,12 @@ Object.defineProperty(Array.prototype, 'copy', {
|
|||
|
||||
Object.defineProperty(Array.prototype, 'dofilter', {
|
||||
value: function(fn) {
|
||||
var j = 0;
|
||||
this.forEach(function(val,i) {
|
||||
if (fn(val)) {
|
||||
if (i !== j) this[j] = val;
|
||||
j++;
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
if (!fn.call(this, this[i], i, this)) {
|
||||
this.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
this.length = j;
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
@ -1095,13 +1093,19 @@ Object.defineProperty(Array.prototype, 'scale', {
|
|||
return this.map(function(x) { return x*s; });
|
||||
}});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'sorted', {
|
||||
value: function() {
|
||||
return this.toSorted();
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'equal', {
|
||||
value: function(b) {
|
||||
if (this.length !== b.length) return false;
|
||||
if (b == null) return false;
|
||||
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++) {
|
||||
if (!this[i] === b[i])
|
||||
|
|
|
@ -234,7 +234,7 @@ Object.seal(sprite);
|
|||
var animcache = {};
|
||||
var SpriteAnim = {};
|
||||
SpriteAnim.make = function(path) {
|
||||
if (animcache[path]) return animcache[path];
|
||||
if (path in animcache) return animcache[path];
|
||||
var anim;
|
||||
if (io.exists(path.set_ext(".ase")))
|
||||
anim = SpriteAnim.aseprite(path.set_ext(".ase"));
|
||||
|
@ -245,7 +245,7 @@ SpriteAnim.make = function(path) {
|
|||
else if (path.ext() === 'gif')
|
||||
anim = SpriteAnim.gif(path);
|
||||
else
|
||||
return undefined;
|
||||
anim = undefined;
|
||||
|
||||
animcache[path] = anim;
|
||||
return animcache[path];
|
||||
|
|
|
@ -119,6 +119,27 @@ qq = 'ms';
|
|||
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.say = function(msg) {
|
||||
msg += "\n";
|
||||
|
@ -181,14 +202,19 @@ console.doc = {
|
|||
|
||||
globalThis.global = globalThis;
|
||||
|
||||
var profcache = {};
|
||||
|
||||
function use(file, env = {}, script)
|
||||
{
|
||||
file = Resources.find_script(file);
|
||||
var st = profile.now();
|
||||
|
||||
profcache[file] ??= [];
|
||||
|
||||
if (use.cache[file]) {
|
||||
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;
|
||||
}
|
||||
console.info(`slurping ${file}`);
|
||||
|
@ -197,7 +223,8 @@ function use(file, env = {}, script)
|
|||
var fn = os.eval(file,script);
|
||||
use.cache[file] = fn;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -429,6 +456,10 @@ prosperon.touchrelease = function(touches){};
|
|||
prosperon.touchmove = function(touches){};
|
||||
prosperon.clipboardpaste = function(str){};
|
||||
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)
|
||||
console.warn(debug.log.time[i].map(x=>profile.ms(x)));
|
||||
};
|
||||
|
@ -567,6 +598,8 @@ function world_start() {
|
|||
world.phys = 2;
|
||||
world.zoom = 1;
|
||||
world._ed = { selectable: false };
|
||||
world.ur = {};
|
||||
world.ur.fresh = {};
|
||||
game.cam = world;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
globalThis.entityreport = {};
|
||||
|
||||
function obj_unique_name(name, obj) {
|
||||
name = name.replaceAll('.', '_');
|
||||
if (!(name in obj)) return name;
|
||||
|
@ -129,6 +131,7 @@ var gameobject = {
|
|||
|
||||
stop.remain = seconds;
|
||||
stop.seconds = seconds;
|
||||
stop.pct = function() { return 1 - (stop.remain/stop.seconds); };
|
||||
|
||||
function update(dt) {
|
||||
stop.remain -= dt;
|
||||
|
@ -140,9 +143,7 @@ var gameobject = {
|
|||
return stop;
|
||||
},
|
||||
|
||||
cry(file) {
|
||||
return audio.cry(file);
|
||||
},
|
||||
cry(file) { return audio.cry(file); },
|
||||
|
||||
set pos(x) { this.set_pos(x); },
|
||||
get pos() { return this.rpos; },
|
||||
|
@ -215,6 +216,7 @@ var gameobject = {
|
|||
nothing
|
||||
*/
|
||||
spawn(text, config, callback) {
|
||||
var st = profile.now();
|
||||
var ent = os.make_gameobject();
|
||||
ent.guid = prosperon.guid();
|
||||
ent.components = {};
|
||||
|
@ -327,13 +329,14 @@ var gameobject = {
|
|||
for (var i in ent.objects)
|
||||
ent.ur.fresh.objects[i] = ent.objects[i].instance_obj();
|
||||
|
||||
profile.addreport(entityreport, ent.ur.name, st);
|
||||
return ent;
|
||||
},
|
||||
|
||||
/* Reparent 'this' to be 'parent's child */
|
||||
reparent(parent) {
|
||||
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) {
|
||||
console.warn("not reparenting ...");
|
||||
console.warn(`${this.master} is the same as ${parent}`);
|
||||
|
@ -731,7 +734,7 @@ game.loadurs = function() {
|
|||
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;
|
||||
var newur = ur_from_file(file);
|
||||
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;
|
||||
var newur = ur_from_file(file);
|
||||
if (!newur) continue;
|
||||
|
|
|
@ -36,6 +36,8 @@ pressrep
|
|||
down
|
||||
*/
|
||||
|
||||
function keycode(name) { return charCodeAt(name); }
|
||||
|
||||
function keyname_extd(key)
|
||||
{
|
||||
if (key > 289 && key < 302) {
|
||||
|
@ -67,7 +69,7 @@ function modstr()
|
|||
|
||||
prosperon.keydown = function(key, repeat)
|
||||
{
|
||||
prosperon.keys[key] = key;
|
||||
prosperon.keys[key] = true;
|
||||
|
||||
if (key == 341 || key == 345)
|
||||
mod.ctrl = 1;
|
||||
|
@ -179,7 +181,7 @@ input.mouse.normal.doc = "Set the mouse to show again after hiding.";
|
|||
input.keyboard = {};
|
||||
input.keyboard.down = function(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ audio.dsp = dspsound;
|
|||
audio.cry = function(file)
|
||||
{
|
||||
var player = audio.play(file);
|
||||
if (!player) return;
|
||||
|
||||
player.guid = prosperon.guid();
|
||||
cries[player.guid] = player;
|
||||
player.ended = function() { delete cries[player.guid]; player = undefined; }
|
||||
|
@ -46,15 +48,19 @@ var song;
|
|||
audio.music = function(file, fade = 0) {
|
||||
if (!fade) {
|
||||
song = audio.play(file);
|
||||
song.loop = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var temp = audio.play(file);
|
||||
if (!temp) return;
|
||||
|
||||
temp.volume = 0;
|
||||
var temp2 = song;
|
||||
tween(temp, 'volume', 1, fade);
|
||||
tween(temp2, 'volume', 0, fade);
|
||||
song = temp;
|
||||
song.loop = true;
|
||||
}
|
||||
|
||||
audio.dsp.mix = function(to) {
|
||||
|
|
|
@ -191,7 +191,6 @@ Cmdline.register_order("edit", function() {
|
|||
}
|
||||
|
||||
window.size = [1280, 720];
|
||||
|
||||
window.mode = window.modetypes.full;
|
||||
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}.`);
|
||||
|
||||
game.engine_start(function() {
|
||||
render.set_font("fonts/c64.ttf", 8);
|
||||
global.app = actor.spawn("game.js");
|
||||
if (project.icon) window.set_icon(game.texture(project.icon));
|
||||
render.set_font("fonts/c64.ttf", 8);
|
||||
game.camera = world.spawn("scripts/camera2d");
|
||||
});
|
||||
}, "Play the game present in this folder.");
|
||||
|
|
|
@ -120,7 +120,7 @@ var tween = function(obj, val, to, time)
|
|||
|
||||
var Tween = {
|
||||
default: {
|
||||
loop: "restart",
|
||||
loop: "hold",
|
||||
/*
|
||||
loop types
|
||||
none: when done, return to first value
|
||||
|
|
|
@ -200,6 +200,7 @@ static sapp_desc start_desc = {
|
|||
.cleanup_cb = c_clean,
|
||||
.event_cb = c_event,
|
||||
.logger.func = sg_logging,
|
||||
.win32_console_create = false,
|
||||
};
|
||||
|
||||
sapp_desc sokol_main(int argc, char **argv) {
|
||||
|
|
Loading…
Reference in a new issue