--amend
This commit is contained in:
parent
261b373a75
commit
cd7733407d
|
@ -3,6 +3,7 @@ var a_db = {};
|
||||||
|
|
||||||
actor.spawn = function(script, config){
|
actor.spawn = function(script, config){
|
||||||
if (typeof script !== 'string') return undefined;
|
if (typeof script !== 'string') return undefined;
|
||||||
|
console.info(`spawning actor with script ${script}`);
|
||||||
if (!a_db[script]) a_db[script] = io.slurp(script);
|
if (!a_db[script]) a_db[script] = io.slurp(script);
|
||||||
var padawan = Object.create(actor);
|
var padawan = Object.create(actor);
|
||||||
eval_env(a_db[script], padawan, script);
|
eval_env(a_db[script], padawan, script);
|
||||||
|
|
|
@ -165,9 +165,7 @@ var timescale = 1;
|
||||||
|
|
||||||
var gggstart = game.engine_start;
|
var gggstart = game.engine_start;
|
||||||
game.engine_start = function(s) {
|
game.engine_start = function(s) {
|
||||||
gggstart(process);
|
gggstart(function() { world_start(); s(); }, process);
|
||||||
world_start();
|
|
||||||
s();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function process()
|
function process()
|
||||||
|
|
|
@ -295,6 +295,7 @@ 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() {
|
||||||
|
console.info(`eng start`);
|
||||||
global.mixin("scripts/sound.js");
|
global.mixin("scripts/sound.js");
|
||||||
global.game = actor.spawn("game.js");
|
global.game = actor.spawn("game.js");
|
||||||
if (project.icon) window.set_icon(project.icon);
|
if (project.icon) window.set_icon(project.icon);
|
||||||
|
|
|
@ -1368,7 +1368,7 @@ static const JSCFunctionListEntry js_vector_funcs[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
JSValue js_game_engine_start(JSContext *js, JSValueConst this, int argc, JSValue *argv) {
|
JSValue js_game_engine_start(JSContext *js, JSValueConst this, int argc, JSValue *argv) {
|
||||||
engine_start(argv[0]);
|
engine_start(argv[0],argv[1]);
|
||||||
RETUN;
|
RETUN;
|
||||||
}
|
}
|
||||||
JSValue js_game_object_count(JSContext *js, JSValueConst this) { return number2js(go_count()); }
|
JSValue js_game_object_count(JSContext *js, JSValueConst this) { return number2js(go_count()); }
|
||||||
|
|
|
@ -52,15 +52,16 @@ static int sim_play = SIM_PLAY;
|
||||||
static int argc;
|
static int argc;
|
||||||
static char **args;
|
static char **args;
|
||||||
|
|
||||||
|
static JSValue c_start;
|
||||||
static JSValue c_process_fn;
|
static JSValue c_process_fn;
|
||||||
|
|
||||||
void c_init() {
|
void c_init() {
|
||||||
mainwin.start = 1;
|
mainwin.start = 1;
|
||||||
window_resize(sapp_width(), sapp_height());
|
window_resize(sapp_width(), sapp_height());
|
||||||
// script_evalf("world_start();");
|
|
||||||
render_init();
|
render_init();
|
||||||
set_icon("icons/moon.gif");
|
set_icon("icons/moon.gif");
|
||||||
particle_init();
|
particle_init();
|
||||||
|
script_call_sym(c_start,0,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void c_frame() { script_call_sym(c_process_fn,0,NULL); }
|
void c_frame() { script_call_sym(c_process_fn,0,NULL); }
|
||||||
|
@ -230,8 +231,9 @@ int main(int argc, char **argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void engine_start(JSValue procfn)
|
void engine_start(JSValue start, JSValue procfn)
|
||||||
{
|
{
|
||||||
|
c_start = start;
|
||||||
c_process_fn = procfn;
|
c_process_fn = procfn;
|
||||||
|
|
||||||
sound_init();
|
sound_init();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
double apptime();
|
double apptime();
|
||||||
void print_stacktrace();
|
void print_stacktrace();
|
||||||
void engine_start(JSValue proc_fn); /* fn runs after the engine starts */
|
void engine_start(JSValue start_fn, JSValue proc_fn); /* fn runs after the engine starts */
|
||||||
|
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue