Compare commits
No commits in common. "5bb7ea32bf7ecbe6d536d18ccd7b85edf17033bf" and "127569ee037c1b27e202953ea8e1f3e4b9d0345f" have entirely different histories.
5bb7ea32bf
...
127569ee03
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -27,6 +27,6 @@ primum*
|
|||
Prosperon*
|
||||
prosperon*
|
||||
*.icns
|
||||
game.zip
|
||||
game.cdb
|
||||
icon.ico
|
||||
steam/
|
39
Makefile
39
Makefile
|
@ -4,10 +4,6 @@ MAKEDIR != pwd
|
|||
# Options
|
||||
# NDEBUG --- build with debugging symbols and logging
|
||||
|
||||
ifeq ($(ARCH),)
|
||||
ARCH != uname -m
|
||||
endif
|
||||
|
||||
CXX:=$(CC)
|
||||
|
||||
# Temp to strip long emcc paths to just emcc
|
||||
|
@ -21,15 +17,6 @@ LD = $(CC)
|
|||
STEAM = steam/sdk
|
||||
STEAMAPI =
|
||||
|
||||
ifeq ($(CC), emcc)
|
||||
LDFLAGS += -sUSE_WEBGPU --shell-file shell.html
|
||||
CPPFLAGS += -Wbad-function-cast -Wcast-function-type -sSTACK_SIZE=5MB -sALLOW_MEMORY_GROWTH
|
||||
OPT = 0
|
||||
NDEBUG = 1
|
||||
AR = emar
|
||||
ARCH:= wasm
|
||||
endif
|
||||
|
||||
CCC != $(CC) -v
|
||||
ifneq ($(findstring clangcc , $(CCC)),)
|
||||
LDFLAGS += -Wl,-rpath=./
|
||||
|
@ -55,6 +42,13 @@ ifdef NQOA
|
|||
CPPFLAGS += -DNQOA
|
||||
endif
|
||||
|
||||
ifeq ($(CC), emcc)
|
||||
LDFLAGS += --closure 1 --emrun --preload-file game.cdb
|
||||
OPT = 0
|
||||
NDEBUG = 1
|
||||
AR = emar
|
||||
endif
|
||||
|
||||
ifdef NDEBUG
|
||||
CPPFLAGS += -DNDEBUG
|
||||
else
|
||||
|
@ -94,7 +88,11 @@ PKGCMD = tar --directory --exclude="./*.a" --exclude="./obj" -czf $(DISTDIR)/$(D
|
|||
ZIP = .tar.gz
|
||||
UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
||||
|
||||
INFO := $(INFO)_$(ARCH)
|
||||
ifeq ($(ARCH),)
|
||||
ARCH != uname -m
|
||||
endif
|
||||
|
||||
INFO :=$(INFO)_$(ARCH)
|
||||
|
||||
ifeq ($(OS), Windows_NT) # then WINDOWS
|
||||
PLATFORM := win64
|
||||
|
@ -120,8 +118,8 @@ else ifeq ($(OS), IOS)
|
|||
INFO :=$(INFO)_ios
|
||||
else ifeq ($(CC), emcc) # Then WEB
|
||||
OS := Web
|
||||
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
|
||||
CPPFLAGS += -DNSTEAM
|
||||
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sTOTAL_MEMORY=128MB -sSTACK_SIZE=5MB
|
||||
CPPFLAGS += -dNSTEAM -sASSERTIONS=2
|
||||
LDLIBS += GL openal c m dl
|
||||
STEAMAPI :=
|
||||
EXT = .html
|
||||
|
@ -167,9 +165,6 @@ includeflag := $(addprefix -I, $(includeflag))
|
|||
|
||||
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types
|
||||
|
||||
ifeq ($(INFO),_)
|
||||
INFO :=
|
||||
endif
|
||||
APP = prosperon
|
||||
NAME = $(APP)$(INFO)$(EXT)
|
||||
SEM != git describe --tags --abbrev=0
|
||||
|
@ -274,7 +269,11 @@ crossmac: Prosperon.icns
|
|||
|
||||
crossweb:
|
||||
make CC=emcc
|
||||
mv $(APP).html index.html
|
||||
mv $(APP)_$(ARCH).html index.html
|
||||
|
||||
playweb:
|
||||
make crossweb
|
||||
emrun index.html
|
||||
|
||||
clean:
|
||||
@echo Cleaning project
|
||||
|
|
10
config.js
10
config.js
|
@ -1,10 +0,0 @@
|
|||
console.stdout_lvl = 4;
|
||||
say(`config after std`);
|
||||
window.size = [600,600];
|
||||
window.rendersize = [200,200];
|
||||
say(`config after window size`);
|
||||
|
||||
globalThis.gamestate = {};
|
||||
gamestate.grid = 10;
|
||||
//window.title = "Accio!";
|
||||
say(`end of config`);
|
|
@ -8,7 +8,6 @@ game.loadurs();
|
|||
console.info(`window size: ${window.size}, render size: ${window.rendersize}`);
|
||||
|
||||
player[0].control(debug);
|
||||
render.clear_color([35,60,92,255].map(x => x/255));
|
||||
|
||||
var show_frame = true;
|
||||
|
||||
|
@ -487,7 +486,7 @@ var editor = {
|
|||
render.text("lock", obj,screenpos());
|
||||
});
|
||||
|
||||
render.grid(1, editor.grid_size, editor.grid_color);
|
||||
render.grid(1, editor.grid_size, Color.Editor.grid.alpha(0.3));
|
||||
var startgrid = game.camera.view2world([-20,0]).map(function(x) { return Math.snap(x, editor.grid_size); });
|
||||
var endgrid = game.camera.view2world([window.width, window.height]);
|
||||
|
||||
|
|
|
@ -159,7 +159,6 @@ globalThis.say = console.say;
|
|||
globalThis.print = console.print;
|
||||
|
||||
console.pprint = function(msg,lvl = 0) {
|
||||
|
||||
if (typeof msg === 'object')
|
||||
msg = JSON.stringify(msg, null, 2);
|
||||
|
||||
|
|
|
@ -244,7 +244,6 @@ Cmdline.register_order("play", function(argv) {
|
|||
global.mixin("config.js");
|
||||
if (project.title) window.title = project.title;
|
||||
|
||||
|
||||
if (window.rendersize.equal([0,0])) window.rendersize = window.size;
|
||||
console.info(`Starting game with window size ${window.size} and render ${window.rendersize}.`);
|
||||
|
||||
|
@ -259,7 +258,7 @@ Cmdline.register_order("play", function(argv) {
|
|||
Cmdline.register_order("pack", function(str) {
|
||||
var packname;
|
||||
if (str.length === 0)
|
||||
packname = "game.zip";
|
||||
packname = "game.cdb";
|
||||
else if (str.length > 1) {
|
||||
console.warn("Give me a single filename for the pack.");
|
||||
return;
|
||||
|
@ -268,22 +267,14 @@ Cmdline.register_order("pack", function(str) {
|
|||
|
||||
say(`Packing into ${packname}`);
|
||||
|
||||
io.pack_start(packname);
|
||||
var files = io.ls('.');
|
||||
files = files.filter(f => !f.startsWith('.git'));
|
||||
files = files.filter(f => !f.startsWith('.nova'));
|
||||
files = files.filter(f => !f.includes('.DS_Store'));
|
||||
files = files.filter(f => !f.startsWith('.gitignore'));
|
||||
say(files);
|
||||
for (var f of files)
|
||||
io.pack_add(f);
|
||||
io.pack_end();
|
||||
// io.pack_engine(packname);
|
||||
io.chmod(packname, 666);
|
||||
}, "Pack the game into the given name.", "NAME");
|
||||
|
||||
Cmdline.register_order("cdb", function(argv) {
|
||||
var cdb = "game.zip";
|
||||
var cdb = "game.cdb";
|
||||
if (!io.exists(cdb)) {
|
||||
say(`No 'game.zip' present.`);
|
||||
say(`No 'game.cdb' present.`);
|
||||
return;
|
||||
}
|
||||
if (argv.length === 0) {
|
||||
|
|
|
@ -97,6 +97,7 @@ void mYughLog(int category, int priority, int line, const char *file, const char
|
|||
raise(SIGTRAP);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -104,13 +105,10 @@ void mYughLog(int category, int priority, int line, const char *file, const char
|
|||
void log_print(const char *str)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
fprintf(stdout, str);
|
||||
fprintf(writeout, str);
|
||||
fflush(stdout);
|
||||
#else
|
||||
printf(str);
|
||||
fflush(stdout);
|
||||
fprintf(stdout, str);
|
||||
#endif
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data) {
|
||||
|
|
|
@ -120,11 +120,6 @@ JSValue strarr2js(char **c)
|
|||
return arr;
|
||||
}
|
||||
|
||||
JSValue js2strarr(JSValue v)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JSValue number2js(double g) { return JS_NewFloat64(js,g); }
|
||||
double js2number(JSValue v) {
|
||||
double g;
|
||||
|
@ -611,11 +606,6 @@ JSC_CCALL(render_end_pass,
|
|||
JSC_SCALL(render_text_size, ret = bb2js(text_bb(str, js2number(argv[1]), js2number(argv[2]), 1)))
|
||||
JSC_CCALL(render_set_camera, useproj = projection)
|
||||
JSC_CCALL(render_set_window, useproj = hudproj)
|
||||
JSC_CCALL(render_clear_color,
|
||||
sg_color c;
|
||||
rgba2floats(&c, js2color(argv[0]));
|
||||
pass_action.colors[0].clear_value = c;
|
||||
)
|
||||
|
||||
static const JSCFunctionListEntry js_render_funcs[] = {
|
||||
MIST_FUNC_DEF(render, grid, 3),
|
||||
|
@ -631,7 +621,6 @@ static const JSCFunctionListEntry js_render_funcs[] = {
|
|||
MIST_FUNC_DEF(render, text_size, 3),
|
||||
MIST_FUNC_DEF(render, set_camera, 0),
|
||||
MIST_FUNC_DEF(render, set_window, 0),
|
||||
MIST_FUNC_DEF(render, clear_color, 1),
|
||||
};
|
||||
|
||||
JSC_CCALL(gui_flush, text_flush(&useproj));
|
||||
|
@ -880,10 +869,6 @@ JSValue js_io_chmod(JSContext *js, JSValue this, int argc, JSValue *argv)
|
|||
|
||||
JSC_SCALL(io_save_qoa, save_qoa(str))
|
||||
|
||||
JSC_SCALL(io_pack_start, pack_start(str))
|
||||
JSC_SCALL(io_pack_add, pack_add(str))
|
||||
JSC_CCALL(io_pack_end, pack_end())
|
||||
|
||||
static const JSCFunctionListEntry js_io_funcs[] = {
|
||||
MIST_FUNC_DEF(io, exists,1),
|
||||
MIST_FUNC_DEF(io, ls, 0),
|
||||
|
@ -897,26 +882,12 @@ static const JSCFunctionListEntry js_io_funcs[] = {
|
|||
MIST_FUNC_DEF(io, slurpbytes, 1),
|
||||
MIST_FUNC_DEF(io, slurpwrite, 2),
|
||||
MIST_FUNC_DEF(io, save_qoa,1),
|
||||
MIST_FUNC_DEF(io, pack_start, 1),
|
||||
MIST_FUNC_DEF(io, pack_add, 1),
|
||||
MIST_FUNC_DEF(io, pack_end, 0)
|
||||
};
|
||||
|
||||
JSC_CCALL(debug_draw_gameobject, gameobject_draw_debug(js2gameobject(argv[0]));)
|
||||
|
||||
JSC_GETSET_GLOBAL(disabled_color, color)
|
||||
JSC_GETSET_GLOBAL(sleep_color, color)
|
||||
JSC_GETSET_GLOBAL(dynamic_color, color)
|
||||
JSC_GETSET_GLOBAL(kinematic_color, color)
|
||||
JSC_GETSET_GLOBAL(static_color, color)
|
||||
|
||||
static const JSCFunctionListEntry js_debug_funcs[] = {
|
||||
MIST_FUNC_DEF(debug, draw_gameobject, 1),
|
||||
CGETSET_ADD(global, disabled_color),
|
||||
CGETSET_ADD(global, sleep_color),
|
||||
CGETSET_ADD(global, dynamic_color),
|
||||
CGETSET_ADD(global, kinematic_color),
|
||||
CGETSET_ADD(global, static_color),
|
||||
MIST_FUNC_DEF(debug, draw_gameobject, 1)
|
||||
};
|
||||
|
||||
JSC_CCALL(physics_sgscale,
|
||||
|
@ -1092,11 +1063,10 @@ static JSValue js_window_get_rendersize(JSContext *js, JSValue this) {
|
|||
}
|
||||
static JSValue js_window_set_rendersize(JSContext *js, JSValue this, JSValue v) {
|
||||
js2window(this)->rendersize = js2vec2(v);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
JSC_GETSET(window, mode, number)
|
||||
static JSValue js_window_get_fullscreen(JSContext *js, JSValue this) { return boolean2js(js2window(this)->fullscreen); }
|
||||
static JSValue js_window_set_fullscreen(JSContext *js, JSValue this, JSValue v) { window_setfullscreen(js2window(this), js2boolean(v)); return JS_UNDEFINED; }
|
||||
static JSValue js_window_set_fullscreen(JSContext *js, JSValue this, JSValue v) { window_setfullscreen(js2window(this), js2boolean(v)); }
|
||||
|
||||
static JSValue js_window_set_title(JSContext *js, JSValue this, JSValue v)
|
||||
{
|
||||
|
@ -1137,12 +1107,12 @@ JSValue js_gameobject_set_rpos(JSContext *js, JSValue this, JSValue val) {
|
|||
return JS_UNDEFINED;
|
||||
}
|
||||
JSValue js_gameobject_get_rpos(JSContext *js, JSValue this) { return cvec22js(cpBodyGetPosition(js2gameobject(this)->body)); }
|
||||
JSValue js_gameobject_set_rangle (JSContext *js, JSValue this, JSValue val) { cpBodySetAngle(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); return JS_UNDEFINED; }
|
||||
JSValue js_gameobject_set_rangle (JSContext *js, JSValue this, JSValue val) { cpBodySetAngle(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); }
|
||||
JSValue js_gameobject_get_rangle (JSContext *js, JSValue this) { return number2js(HMM_RadToTurn*cpBodyGetAngle(js2gameobject(this)->body)); }
|
||||
JSValue js_gameobject_get_rscale(JSContext *js, JSValue this) { return vec32js(js2gameobject(this)->scale); }
|
||||
JSValue js_gameobject_set_rscale(JSContext *js, JSValue this, JSValue val) { js2gameobject(this)->scale = js2vec3(val); return JS_UNDEFINED; }
|
||||
JSValue js_gameobject_set_rscale(JSContext *js, JSValue this, JSValue val) { js2gameobject(this)->scale = js2vec3(val); }
|
||||
JSC_GETSET_BODY(velocity, Velocity, cvec2)
|
||||
JSValue js_gameobject_set_angularvelocity (JSContext *js, JSValue this, JSValue val) { cpBodySetAngularVelocity(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); return JS_UNDEFINED;}
|
||||
JSValue js_gameobject_set_angularvelocity (JSContext *js, JSValue this, JSValue val) { cpBodySetAngularVelocity(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); }
|
||||
JSValue js_gameobject_get_angularvelocity (JSContext *js, JSValue this) { return number2js(HMM_RadToTurn*cpBodyGetAngularVelocity(js2gameobject(this)->body)); }
|
||||
//JSC_GETSET_BODY(moi, Moment, number)
|
||||
JSC_GETSET_BODY(torque, Torque, number)
|
||||
|
|
|
@ -121,6 +121,8 @@ void capture_screen(int x, int y, int w, int h, const char *path)
|
|||
|
||||
#include "HandmadeMath.h"
|
||||
|
||||
struct rgba editorClearColor = {35,60,92,255};
|
||||
|
||||
sg_pass_action pass_action = {0};
|
||||
|
||||
static struct {
|
||||
|
@ -224,17 +226,16 @@ void render_init() {
|
|||
.buffer_pool_size = 1024
|
||||
});
|
||||
|
||||
#ifndef NDEBUG
|
||||
sg_trace_hooks hh = sg_install_trace_hooks(&hooks);
|
||||
#endif
|
||||
|
||||
font_init();
|
||||
debugdraw_init();
|
||||
sprite_initialize();
|
||||
|
||||
model_init();
|
||||
sg_color c;
|
||||
rgba2floats((float*)&c, editorClearColor);
|
||||
|
||||
sg_color c = (sg_color){0,0,0,1};
|
||||
pass_action = (sg_pass_action){
|
||||
.colors[0] = {.load_action = SG_LOADACTION_CLEAR, .clear_value = c},
|
||||
};
|
||||
|
|
|
@ -30,7 +30,6 @@ extern HMM_Vec3 dirl_pos;
|
|||
extern HMM_Mat4 projection;
|
||||
extern HMM_Mat4 hudproj;
|
||||
extern HMM_Mat4 useproj;
|
||||
extern sg_pass_action pass_action;
|
||||
|
||||
struct draw_p {
|
||||
float x;
|
||||
|
|
|
@ -45,29 +45,21 @@ static mz_zip_archive game_cdb;
|
|||
|
||||
int LOADED_GAME = 0;
|
||||
uint8_t *gamebuf;
|
||||
void *zipbuf;
|
||||
|
||||
sfetch_handle_t game_h;
|
||||
|
||||
static void response_cb(const sfetch_response_t *r)
|
||||
{
|
||||
if (r->fetched) {
|
||||
zipbuf = malloc(r->data.size);
|
||||
memcpy(zipbuf, r->data.ptr, r->data.size);
|
||||
mz_zip_reader_init_mem(&game_cdb, zipbuf, r->data.size,0);
|
||||
|
||||
mz_zip_reader_init_mem(&game_cdb, r->data.ptr, r->data.size,0);
|
||||
LOADED_GAME = 1;
|
||||
}
|
||||
if (r->finished) {
|
||||
LOADED_GAME = 1;
|
||||
void *buf = sfetch_unbind_buffer(r->handle);
|
||||
free(buf);
|
||||
if (r->failed)
|
||||
LOADED_GAME = -1;
|
||||
if (r->failed) {
|
||||
LOADED_GAME = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *gamedata;
|
||||
|
||||
void resources_init() {
|
||||
sfetch_setup(&(sfetch_desc_t){
|
||||
.max_requests = 1024,
|
||||
|
@ -75,27 +67,18 @@ void resources_init() {
|
|||
.num_lanes = 8,
|
||||
.logger = { .func = sg_logging },
|
||||
});
|
||||
mz_zip_reader_init_mem(&corecdb, core_cdb, core_cdb_len, 0);
|
||||
gamebuf = malloc(64*1024*1024);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
gamebuf = malloc(8*1024*1024);
|
||||
game_h = sfetch_send(&(sfetch_request_t){
|
||||
.path="game.zip",
|
||||
sfetch_handle_t h = sfetch_send(&(sfetch_request_t){
|
||||
.path="game.cdb",
|
||||
.callback = response_cb,
|
||||
.buffer = {
|
||||
.ptr = gamebuf,
|
||||
.size = 8*1024*1024
|
||||
.size = 64*1024*1024
|
||||
}
|
||||
});
|
||||
#else
|
||||
size_t gamesize;
|
||||
gamebuf = slurp_file("game.zip", &gamesize);
|
||||
if (gamebuf) {
|
||||
mz_zip_reader_init_mem(&game_cdb, gamebuf, gamesize, 0);
|
||||
free(gamebuf);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
mz_zip_reader_init_mem(&corecdb, core_cdb, core_cdb_len, 0);
|
||||
}
|
||||
|
||||
char *get_filename_from_path(char *path, int extension) {
|
||||
|
@ -174,31 +157,10 @@ char **ls(const char *path)
|
|||
return ls_paths;
|
||||
}
|
||||
|
||||
static mz_zip_archive ar;
|
||||
|
||||
void pack_start(const char *name)
|
||||
{
|
||||
memset(&ar, 0, sizeof(ar));
|
||||
int status = mz_zip_writer_init_file(&ar, name, 0);
|
||||
|
||||
}
|
||||
|
||||
void pack_add(const char *path)
|
||||
{
|
||||
mz_zip_writer_add_file(&ar, path, path, NULL, 0, MZ_BEST_COMPRESSION);
|
||||
}
|
||||
|
||||
void pack_end()
|
||||
{
|
||||
mz_zip_writer_finalize_archive(&ar);
|
||||
mz_zip_writer_end(&ar);
|
||||
}
|
||||
|
||||
#else
|
||||
void fill_extensions(char *paths, const char *path, const char *ext)
|
||||
{};
|
||||
char **ls(const char *path) { return NULL; }
|
||||
void pack(const char *name, const char *dir) {}
|
||||
#endif
|
||||
|
||||
char *str_replace_ext(const char *s, const char *newext) {
|
||||
|
|
|
@ -18,9 +18,6 @@ char **ls(const char *path);
|
|||
int cp(const char *p1, const char *p2);
|
||||
int fexists(const char *path);
|
||||
time_t file_mod_secs(const char *file);
|
||||
void pack_start(const char *name);
|
||||
void pack_add(const char *path);
|
||||
void pack_end();
|
||||
|
||||
char *dirname(const char *path);
|
||||
|
||||
|
@ -30,4 +27,14 @@ int slurp_write(const char *txt, const char *filename, size_t len);
|
|||
|
||||
char *seprint(char *fmt, ...);
|
||||
|
||||
static inline void *stbarrdup(void *mem, size_t size, int len) {
|
||||
void *out = NULL;
|
||||
arrsetlen(out, len);
|
||||
memcpy(out,mem,size*len);
|
||||
return out;
|
||||
}
|
||||
|
||||
#define arrconcat(a,b) do{for (int i = 0; i < arrlen(b); i++) arrput(a,b[i]);}while(0)
|
||||
#define arrdup(a) (stbarrdup(a, sizeof(*a), arrlen(a)))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,8 +34,10 @@ void script_stop()
|
|||
#ifndef LEAK
|
||||
return;
|
||||
#endif
|
||||
printf("FREEING CONTEXT\n");
|
||||
|
||||
script_gc();
|
||||
|
||||
JS_FreeContext(js);
|
||||
js = NULL;
|
||||
JS_FreeRuntime(rt);
|
||||
|
|
|
@ -20,8 +20,6 @@ struct window mainwin = {
|
|||
.vsync = 1,
|
||||
.enable_clipboard = 0,
|
||||
.enable_dragndrop = 0,
|
||||
.size = (HMM_Vec2){640,400},
|
||||
.rendersize = (HMM_Vec2){640,400},
|
||||
};
|
||||
|
||||
static struct window *windows = NULL;
|
||||
|
|
|
@ -53,10 +53,8 @@ static int sim_play = SIM_PLAY;
|
|||
static int argc;
|
||||
static char **args;
|
||||
|
||||
static JSValue c_start = JS_UNDEFINED;
|
||||
static JSValue c_process_fn = JS_UNDEFINED;
|
||||
|
||||
static int PLAYSTART = 0;
|
||||
static JSValue c_start;
|
||||
static JSValue c_process_fn;
|
||||
|
||||
void c_init() {
|
||||
mainwin.start = 1;
|
||||
|
@ -64,28 +62,13 @@ void c_init() {
|
|||
phys2d_init();
|
||||
render_init();
|
||||
particle_init();
|
||||
if (!JS_IsUndefined(c_start)) {
|
||||
script_call_sym(c_start,0,NULL);
|
||||
JS_FreeValue(js, c_start);
|
||||
}
|
||||
script_call_sym(c_start,0,NULL);
|
||||
JS_FreeValue(js, c_start);
|
||||
}
|
||||
|
||||
void c_frame() {
|
||||
sfetch_dowork();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (PLAYSTART)
|
||||
script_call_sym(c_process_fn,0,NULL);
|
||||
else if (LOADED_GAME) {
|
||||
PLAYSTART = 1;
|
||||
printf("LOADED GAME\n");
|
||||
script_evalf("cmd_args('play');");
|
||||
script_call_sym(c_start,0,NULL);
|
||||
JS_FreeValue(js, c_start);
|
||||
window_resize(sapp_width(), sapp_height());
|
||||
}
|
||||
#else
|
||||
script_call_sym(c_process_fn,0,NULL);
|
||||
#endif
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void cleanup()
|
||||
|
@ -217,8 +200,8 @@ static sapp_desc start_desc = {
|
|||
.frame_cb = c_frame,
|
||||
.cleanup_cb = c_clean,
|
||||
.event_cb = c_event,
|
||||
.logger.func = sg_logging,
|
||||
.win32_console_create = false,
|
||||
.logger.func = sg_logging
|
||||
};
|
||||
|
||||
sapp_desc sokol_main(int argc, char **argv) {
|
||||
|
@ -233,7 +216,6 @@ sapp_desc sokol_main(int argc, char **argv) {
|
|||
stm_setup(); /* time */
|
||||
script_startup();
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
int argsize = 0;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
argsize += strlen(argv[i]);
|
||||
|
@ -248,9 +230,10 @@ sapp_desc sokol_main(int argc, char **argv) {
|
|||
if (argc > i+1) strcat(cmdstr, " ");
|
||||
}
|
||||
|
||||
script_evalf("cmd_args('%s');", cmdstr);
|
||||
#endif
|
||||
// while (!LOADED_GAME)
|
||||
// sfetch_dowork();
|
||||
|
||||
script_evalf("cmd_args('%s');", cmdstr);
|
||||
return start_desc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue