ld56 updates
This commit is contained in:
parent
f928f3e8a2
commit
8465fb53f7
|
@ -820,6 +820,11 @@ Object.defineProperty(Array.prototype, "rotate", {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Array.random = function(arr) {
|
||||||
|
if (!Array.isArray(arr)) return;
|
||||||
|
return arr[Math.floor(Math.random()*arr.length)];
|
||||||
|
}
|
||||||
|
|
||||||
function make_swizz() {
|
function make_swizz() {
|
||||||
function setelem(n) {
|
function setelem(n) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -125,7 +125,7 @@ input.mouse.screenpos = function () {
|
||||||
return mousepos.slice();
|
return mousepos.slice();
|
||||||
};
|
};
|
||||||
input.mouse.worldpos = function () {
|
input.mouse.worldpos = function () {
|
||||||
return game.camera.view2world(mousepos);
|
return prosperon.camera.screen2world(mousepos);
|
||||||
};
|
};
|
||||||
input.mouse.disabled = function () {
|
input.mouse.disabled = function () {
|
||||||
input.mouse_mode(1);
|
input.mouse_mode(1);
|
||||||
|
@ -147,7 +147,8 @@ input.mouse.set_custom_cursor = function (img, mode = input.mouse.cursor.default
|
||||||
};
|
};
|
||||||
|
|
||||||
input.mouse.button = {
|
input.mouse.button = {
|
||||||
/* left, right, middle mouse */ 0: "lm",
|
/* left, right, middle mouse */
|
||||||
|
0: "lm",
|
||||||
1: "rm",
|
1: "rm",
|
||||||
2: "mm",
|
2: "mm",
|
||||||
};
|
};
|
||||||
|
|
|
@ -515,8 +515,8 @@ Register.add_cb("update", true).doc = "Called once per frame.";
|
||||||
Register.add_cb("physupdate", true);
|
Register.add_cb("physupdate", true);
|
||||||
Register.add_cb("gui", true);
|
Register.add_cb("gui", true);
|
||||||
Register.add_cb("hud", true, render.flush);
|
Register.add_cb("hud", true, render.flush);
|
||||||
Register.add_cb("draw", true);
|
Register.add_cb("draw", true, render.flush);
|
||||||
Register.add_cb("imgui", true);
|
Register.add_cb("imgui", true, render.flush);
|
||||||
|
|
||||||
var Event = {
|
var Event = {
|
||||||
events: {},
|
events: {},
|
||||||
|
|
|
@ -233,7 +233,6 @@ var pipe_shaders = new WeakMap();
|
||||||
render.use_shader = function use_shader(shader, pipeline) {
|
render.use_shader = function use_shader(shader, pipeline) {
|
||||||
pipeline ??= base_pipeline;
|
pipeline ??= base_pipeline;
|
||||||
if (typeof shader === "string") shader = make_shader(shader);
|
if (typeof shader === "string") shader = make_shader(shader);
|
||||||
if (cur.shader === shader) return;
|
|
||||||
|
|
||||||
if (!pipe_shaders.has(shader)) pipe_shaders.set(shader, new WeakMap());
|
if (!pipe_shaders.has(shader)) pipe_shaders.set(shader, new WeakMap());
|
||||||
var shader_pipelines = pipe_shaders.get(shader);
|
var shader_pipelines = pipe_shaders.get(shader);
|
||||||
|
@ -571,13 +570,14 @@ function shader_apply_material(shader, material = {}, old = {}) {
|
||||||
// Creates a binding object for a given mesh and shader
|
// Creates a binding object for a given mesh and shader
|
||||||
var bcache = new WeakMap();
|
var bcache = new WeakMap();
|
||||||
function sg_bind(mesh, ssbo) {
|
function sg_bind(mesh, ssbo) {
|
||||||
if (cur.mesh === mesh && cur.ssbo === ssbo) {
|
/* if (cur.bind && cur.mesh === mesh && cur.ssbo === ssbo) {
|
||||||
cur.bind.ssbo = [ssbo];
|
cur.bind.ssbo = [ssbo];
|
||||||
cur.bind.images = cur.images;
|
cur.bind.images = cur.images;
|
||||||
cur.bind.samplers = cur.samplers;
|
cur.bind.samplers = cur.samplers;
|
||||||
|
console.info(json.encode(cur.bind));
|
||||||
render.setbind(cur.bind);
|
render.setbind(cur.bind);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/* if (bcache.has(cur.shader) && bcache.get(cur.shader).has(mesh)) {
|
/* if (bcache.has(cur.shader) && bcache.get(cur.shader).has(mesh)) {
|
||||||
cur.bind = bcache.get(cur.shader).get(mesh);
|
cur.bind = bcache.get(cur.shader).get(mesh);
|
||||||
|
@ -737,7 +737,7 @@ render.sprites = function render_sprites() {
|
||||||
};
|
};
|
||||||
|
|
||||||
render.circle = function render_circle(pos, radius, color, inner_radius = 1) {
|
render.circle = function render_circle(pos, radius, color, inner_radius = 1) {
|
||||||
check_flush(undefined);
|
check_flush();
|
||||||
|
|
||||||
if (inner_radius >= 1) inner_radius = inner_radius / radius;
|
if (inner_radius >= 1) inner_radius = inner_radius / radius;
|
||||||
else if (inner_radius < 0) inner_radius = 1.0;
|
else if (inner_radius < 0) inner_radius = 1.0;
|
||||||
|
@ -807,7 +807,7 @@ function poly_e() {
|
||||||
|
|
||||||
function flush_poly() {
|
function flush_poly() {
|
||||||
if (poly_idx === 0) return;
|
if (poly_idx === 0) return;
|
||||||
render.use_shader(polyssboshader);
|
render.use_shader(queued_shader, queued_pipe);
|
||||||
var base = render.make_particle_ssbo(poly_cache.slice(0, poly_idx), poly_ssbo);
|
var base = render.make_particle_ssbo(poly_cache.slice(0, poly_idx), poly_ssbo);
|
||||||
render.use_mat({baseinstance:base});
|
render.use_mat({baseinstance:base});
|
||||||
render.draw(shape.centered_quad, poly_ssbo, poly_idx);
|
render.draw(shape.centered_quad, poly_ssbo, poly_idx);
|
||||||
|
@ -858,16 +858,26 @@ render.boundingbox = function render_boundingbox(bb, color = Color.white) {
|
||||||
render.line(bbox.topoints(bb).wrapped(1), color);
|
render.line(bbox.topoints(bb).wrapped(1), color);
|
||||||
};
|
};
|
||||||
|
|
||||||
render.rectangle = function render_rectangle(lowerleft, upperright, color) {
|
var queued_shader;
|
||||||
|
var queued_pipe;
|
||||||
|
render.rectangle = function render_rectangle(lowerleft, upperright, color, shader = polyssboshader, pipe = base_pipeline) {
|
||||||
var transform = os.make_transform();
|
var transform = os.make_transform();
|
||||||
var wh = [upperright.x - lowerleft.x, upperright.y - lowerleft.y];
|
var wh = [upperright.x - lowerleft.x, upperright.y - lowerleft.y];
|
||||||
var poly = poly_e();
|
var poly = poly_e();
|
||||||
poly.transform.move(vector.midpoint(lowerleft, upperright));
|
poly.transform.move(vector.midpoint(lowerleft, upperright));
|
||||||
poly.transform.scale = [wh.x, wh.y, 1];
|
poly.transform.scale = [wh.x, wh.y, 1];
|
||||||
poly.color = color;
|
poly.color = color;
|
||||||
check_flush(flush_poly);
|
|
||||||
|
queued_shader = shader;
|
||||||
|
queued_pipe = pipe;
|
||||||
|
flush_poly();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
render.rect = function(rect, color, shader, pipe)
|
||||||
|
{
|
||||||
|
render.rectangle([rect.x-rect.w/2, rect.y-rect.h/2], [rect.x+rect.w/2, rect.y+rect.h/2], color, shader, pipe);
|
||||||
|
}
|
||||||
|
|
||||||
render.box = function render_box(pos, wh, color = Color.white) {
|
render.box = function render_box(pos, wh, color = Color.white) {
|
||||||
var poly = poly_e();
|
var poly = poly_e();
|
||||||
poly.transform.move(pos);
|
poly.transform.move(pos);
|
||||||
|
@ -916,7 +926,7 @@ function flush_img() {
|
||||||
if (img_idx === 0) return;
|
if (img_idx === 0) return;
|
||||||
render.use_shader(spritessboshader);
|
render.use_shader(spritessboshader);
|
||||||
var startidx = render.make_sprite_ssbo(img_cache.slice(0, img_idx), sprite_ssbo);
|
var startidx = render.make_sprite_ssbo(img_cache.slice(0, img_idx), sprite_ssbo);
|
||||||
render.use_mat({ baseinstance:startidx});
|
render.use_mat({baseinstance:startidx});
|
||||||
cur.images = [lasttex];
|
cur.images = [lasttex];
|
||||||
render.draw(shape.quad, sprite_ssbo, img_idx);
|
render.draw(shape.quad, sprite_ssbo, img_idx);
|
||||||
lasttex = undefined;
|
lasttex = undefined;
|
||||||
|
@ -960,6 +970,8 @@ var stencil_writer = function stencil_writer(ref)
|
||||||
return pipe;
|
return pipe;
|
||||||
}.hashify();
|
}.hashify();
|
||||||
|
|
||||||
|
render.stencil_writer = stencil_writer;
|
||||||
|
|
||||||
// objects by default draw where the stencil buffer is 0
|
// objects by default draw where the stencil buffer is 0
|
||||||
render.fillmask = function(ref)
|
render.fillmask = function(ref)
|
||||||
{
|
{
|
||||||
|
@ -1041,6 +1053,9 @@ render.image = function image(image, pos, scale, rotation = 0, color = Color.whi
|
||||||
e.image = image;
|
e.image = image;
|
||||||
e.shade = color;
|
e.shade = color;
|
||||||
|
|
||||||
|
flush_img();
|
||||||
|
lasttex = undefined;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
var bb = {};
|
var bb = {};
|
||||||
bb.b = pos.y;
|
bb.b = pos.y;
|
||||||
|
@ -1330,6 +1345,7 @@ prosperon.render = function () {
|
||||||
prosperon.draw();
|
prosperon.draw();
|
||||||
profile.endreport("draws");
|
profile.endreport("draws");
|
||||||
profile.endreport("world");
|
profile.endreport("world");
|
||||||
|
render.fillmask(0);
|
||||||
prosperon.hudcam.size = prosperon.camera.size;
|
prosperon.hudcam.size = prosperon.camera.size;
|
||||||
prosperon.hudcam.transform.pos = [prosperon.hudcam.size.x / 2, prosperon.hudcam.size.y / 2, -100];
|
prosperon.hudcam.transform.pos = [prosperon.hudcam.size.x / 2, prosperon.hudcam.size.y / 2, -100];
|
||||||
render.set_camera(prosperon.hudcam);
|
render.set_camera(prosperon.hudcam);
|
||||||
|
|
|
@ -61,7 +61,7 @@ audio.cry = function (file, bus = audio.bus.sfx) {
|
||||||
var player = audio.play(file, bus);
|
var player = audio.play(file, bus);
|
||||||
if (!player) return;
|
if (!player) return;
|
||||||
player.ended = function () {
|
player.ended = function () {
|
||||||
player.unplug();
|
player?.unplug();
|
||||||
player = undefined;
|
player = undefined;
|
||||||
};
|
};
|
||||||
return player.ended;
|
return player.ended;
|
||||||
|
@ -69,7 +69,6 @@ audio.cry = function (file, bus = audio.bus.sfx) {
|
||||||
|
|
||||||
// This function is called when every audio source is finished
|
// This function is called when every audio source is finished
|
||||||
var killer = Register.appupdate.register(function () {
|
var killer = Register.appupdate.register(function () {
|
||||||
return;
|
|
||||||
for (var src of sources) {
|
for (var src of sources) {
|
||||||
if (!src.loop && (src.frame < src.lastframe || src.frame === src.frames())) {
|
if (!src.loop && (src.frame < src.lastframe || src.frame === src.frames())) {
|
||||||
src.unplug();
|
src.unplug();
|
||||||
|
@ -112,6 +111,11 @@ audio.music = function (file, fade = 0.5) {
|
||||||
song.loop = true;
|
song.loop = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
audio.music.playing = function()
|
||||||
|
{
|
||||||
|
return song;
|
||||||
|
}
|
||||||
|
|
||||||
audio.bus.music = audio.dsp.mix();
|
audio.bus.music = audio.dsp.mix();
|
||||||
audio.bus.music.plugin(audio.bus.master);
|
audio.bus.music.plugin(audio.bus.master);
|
||||||
audio.bus.music.name = "music";
|
audio.bus.music.name = "music";
|
||||||
|
|
|
@ -481,6 +481,7 @@ JSC_CCALL(imgui_tablenextrow, ImGui::TableNextRow())
|
||||||
JSC_CCALL(imgui_tablenextcolumn, ImGui::TableNextColumn())
|
JSC_CCALL(imgui_tablenextcolumn, ImGui::TableNextColumn())
|
||||||
JSC_SCALL(imgui_tablesetupcolumn, ImGui::TableSetupColumn(str))
|
JSC_SCALL(imgui_tablesetupcolumn, ImGui::TableSetupColumn(str))
|
||||||
JSC_CCALL(imgui_tableheadersrow, ImGui::TableHeadersRow())
|
JSC_CCALL(imgui_tableheadersrow, ImGui::TableHeadersRow())
|
||||||
|
JSC_CCALL(imgui_tableangledheadersrow, ImGui::TableAngledHeadersRow())
|
||||||
|
|
||||||
JSC_SCALL(imgui_dnd,
|
JSC_SCALL(imgui_dnd,
|
||||||
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) {
|
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) {
|
||||||
|
@ -838,6 +839,7 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, tablenextcolumn,0),
|
MIST_FUNC_DEF(imgui, tablenextcolumn,0),
|
||||||
MIST_FUNC_DEF(imgui, tablenextrow,0),
|
MIST_FUNC_DEF(imgui, tablenextrow,0),
|
||||||
MIST_FUNC_DEF(imgui, tableheadersrow, 0),
|
MIST_FUNC_DEF(imgui, tableheadersrow, 0),
|
||||||
|
MIST_FUNC_DEF(imgui, tableangledheadersrow, 0),
|
||||||
MIST_FUNC_DEF(imgui, tablesetupcolumn, 1),
|
MIST_FUNC_DEF(imgui, tablesetupcolumn, 1),
|
||||||
MIST_FUNC_DEF(imgui, dnd, 3),
|
MIST_FUNC_DEF(imgui, dnd, 3),
|
||||||
MIST_FUNC_DEF(imgui, dndtarget, 2),
|
MIST_FUNC_DEF(imgui, dndtarget, 2),
|
||||||
|
|
|
@ -20,24 +20,6 @@ void input_clipboard_paste(char *str)
|
||||||
script_evalf("prosperon.clipboardpaste(`%s`);", sapp_get_clipboard_string());
|
script_evalf("prosperon.clipboardpaste(`%s`);", sapp_get_clipboard_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
0 free
|
|
||||||
1 lock
|
|
||||||
*/
|
|
||||||
void set_mouse_mode(int mousemode) { sapp_lock_mouse(mousemode); }
|
|
||||||
|
|
||||||
void cursor_hide() { sapp_show_mouse(0); }
|
|
||||||
void cursor_show() { sapp_show_mouse(1); }
|
|
||||||
|
|
||||||
void cursor_img(const char *path)
|
|
||||||
{
|
|
||||||
/* NSdesting *dest = [NSdesting destingWithUTF8desting:path];
|
|
||||||
NSImage *img = [[NSImage alloc] initWithContentsOfFile:dest];
|
|
||||||
NSCursor *custom = [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(0,0)];
|
|
||||||
[custom set];
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *touch_jstrn(char *dest, int len, sapp_touchpoint *touch, int n)
|
static char *touch_jstrn(char *dest, int len, sapp_touchpoint *touch, int n)
|
||||||
{
|
{
|
||||||
dest[0] = 0;
|
dest[0] = 0;
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
#include "HandmadeMath.h"
|
#include "HandmadeMath.h"
|
||||||
#include "sokol_app.h"
|
#include "sokol_app.h"
|
||||||
|
|
||||||
void cursor_hide();
|
|
||||||
void cursor_show();
|
|
||||||
void cursor_img(const char *path);
|
|
||||||
void set_mouse_mode(int mousemode);
|
|
||||||
void touch_start(sapp_touchpoint *touch, int n);
|
void touch_start(sapp_touchpoint *touch, int n);
|
||||||
void touch_move(sapp_touchpoint *touch, int n);
|
void touch_move(sapp_touchpoint *touch, int n);
|
||||||
void touch_end(sapp_touchpoint *touch, int n);
|
void touch_end(sapp_touchpoint *touch, int n);
|
||||||
|
|
|
@ -1174,6 +1174,7 @@ JSC_CCALL(render_make_sprite_ssbo,
|
||||||
JSValue sub = js_getpropidx(array,i);
|
JSValue sub = js_getpropidx(array,i);
|
||||||
|
|
||||||
transform *tr = js2transform(js_getpropstr(sub, "transform"));
|
transform *tr = js2transform(js_getpropstr(sub, "transform"));
|
||||||
|
HMM_Vec2 pos = js2vec2(js_getpropstr(sub, "pos"));
|
||||||
JSValue image = js_getpropstr(sub, "image");
|
JSValue image = js_getpropstr(sub, "image");
|
||||||
texture *t = js2texture(js_getpropstr(image, "texture"));
|
texture *t = js2texture(js_getpropstr(image, "texture"));
|
||||||
HMM_Vec3 tscale;
|
HMM_Vec3 tscale;
|
||||||
|
@ -1184,6 +1185,7 @@ JSC_CCALL(render_make_sprite_ssbo,
|
||||||
tscale.z = 1;
|
tscale.z = 1;
|
||||||
tr->scale = HMM_MulV3(tr->scale, tscale);
|
tr->scale = HMM_MulV3(tr->scale, tscale);
|
||||||
}
|
}
|
||||||
|
tr->pos.xy = HMM_AddV2(tr->pos.xy, pos);
|
||||||
|
|
||||||
ms[i].model = transform2mat(tr);
|
ms[i].model = transform2mat(tr);
|
||||||
ms[i].rect = js2vec4(js_getpropstr(image,"rect"));
|
ms[i].rect = js2vec4(js_getpropstr(image,"rect"));
|
||||||
|
@ -1191,6 +1193,8 @@ JSC_CCALL(render_make_sprite_ssbo,
|
||||||
|
|
||||||
if (t)
|
if (t)
|
||||||
tr->scale = HMM_DivV3(tr->scale, tscale);
|
tr->scale = HMM_DivV3(tr->scale, tscale);
|
||||||
|
|
||||||
|
tr->pos.xy = HMM_SubV2(tr->pos.xy, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = sg_append_buffer(*b, (&(sg_range){
|
int offset = sg_append_buffer(*b, (&(sg_range){
|
||||||
|
@ -1779,16 +1783,16 @@ static const JSCFunctionListEntry js_game_funcs[] = {
|
||||||
|
|
||||||
JSC_CCALL(input_show_keyboard, sapp_show_keyboard(js2boolean(argv[0])))
|
JSC_CCALL(input_show_keyboard, sapp_show_keyboard(js2boolean(argv[0])))
|
||||||
JSValue js_input_keyboard_shown(JSContext *js, JSValue self) { return boolean2js(sapp_keyboard_shown()); }
|
JSValue js_input_keyboard_shown(JSContext *js, JSValue self) { return boolean2js(sapp_keyboard_shown()); }
|
||||||
JSC_CCALL(input_mouse_mode, set_mouse_mode(js2number(argv[0])))
|
JSC_CCALL(input_mouse_lock, sapp_lock_mouse(js2number(argv[0])))
|
||||||
JSC_CCALL(input_mouse_cursor, sapp_set_mouse_cursor(js2number(argv[0])))
|
JSC_CCALL(input_mouse_cursor, sapp_set_mouse_cursor(js2number(argv[0])))
|
||||||
JSC_SCALL(input_cursor_img, cursor_img(str))
|
JSC_CCALL(input_mouse_show, sapp_show_mouse(js2boolean(argv[0])))
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_input_funcs[] = {
|
static const JSCFunctionListEntry js_input_funcs[] = {
|
||||||
MIST_FUNC_DEF(input, show_keyboard, 1),
|
MIST_FUNC_DEF(input, show_keyboard, 1),
|
||||||
MIST_FUNC_DEF(input, keyboard_shown, 0),
|
MIST_FUNC_DEF(input, keyboard_shown, 0),
|
||||||
MIST_FUNC_DEF(input, mouse_mode, 1),
|
|
||||||
MIST_FUNC_DEF(input, mouse_cursor, 1),
|
MIST_FUNC_DEF(input, mouse_cursor, 1),
|
||||||
MIST_FUNC_DEF(input, cursor_img, 1)
|
MIST_FUNC_DEF(input, mouse_show, 1),
|
||||||
|
MIST_FUNC_DEF(input, mouse_lock, 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
JSC_CCALL(prosperon_phys2d_step, phys2d_update(js2number(argv[0])))
|
JSC_CCALL(prosperon_phys2d_step, phys2d_update(js2number(argv[0])))
|
||||||
|
@ -2828,6 +2832,59 @@ static const JSCFunctionListEntry js_performance_funcs[] = {
|
||||||
MIST_FUNC_DEF(performance, call_fn_n, 3)
|
MIST_FUNC_DEF(performance, call_fn_n, 3)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JSC_CCALL(geometry_rect_intersect,
|
||||||
|
rect a = js2rect(argv[0]);
|
||||||
|
rect b = js2rect(argv[1]);
|
||||||
|
return boolean2js(a.x < (b.x+b.w) &&
|
||||||
|
(a.x + a.w) > b.x &&
|
||||||
|
a.y < (b.y + b.h) &&
|
||||||
|
(a.y + a.h) > b.y );
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(geometry_rect_inside,
|
||||||
|
rect inner = js2rect(argv[0]);
|
||||||
|
rect outer = js2rect(argv[1]);
|
||||||
|
return boolean2js(
|
||||||
|
inner.x >= outer.x &&
|
||||||
|
inner.x + inner.w <= outer.x + outer.w &&
|
||||||
|
inner.y >= outer.y &&
|
||||||
|
inner.y + inner.h <= outer.y + outer.h
|
||||||
|
);
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(geometry_rect_random,
|
||||||
|
rect a = js2rect(argv[0]);
|
||||||
|
return vec22js((HMM_Vec2){
|
||||||
|
a.x + rand_range(-0.5,0.5)*a.w,
|
||||||
|
a.y + rand_range(-0.5,0.5)*a.h
|
||||||
|
});
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(geometry_rect_point_inside,
|
||||||
|
rect a = js2rect(argv[0]);
|
||||||
|
HMM_Vec2 p = js2vec2(argv[1]);
|
||||||
|
return boolean2js(p.x >= a.x-a.w/2 && p.x <= a.x+a.w/2 && p.y <= a.y+a.h/2 && p.y >= a.y-a.h/2);
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(geometry_cwh2rect,
|
||||||
|
HMM_Vec2 c = js2vec2(argv[0]);
|
||||||
|
HMM_Vec2 wh = js2vec2(argv[1]);
|
||||||
|
rect r;
|
||||||
|
r.x = c.x;
|
||||||
|
r.y = c.y;
|
||||||
|
r.w = wh.x;
|
||||||
|
r.h = wh.y;
|
||||||
|
return rect2js(r);
|
||||||
|
)
|
||||||
|
|
||||||
|
static const JSCFunctionListEntry js_geometry_funcs[] = {
|
||||||
|
MIST_FUNC_DEF(geometry, rect_intersect, 2),
|
||||||
|
MIST_FUNC_DEF(geometry, rect_inside, 2),
|
||||||
|
MIST_FUNC_DEF(geometry, rect_random, 1),
|
||||||
|
MIST_FUNC_DEF(geometry, cwh2rect, 2),
|
||||||
|
MIST_FUNC_DEF(geometry, rect_point_inside, 2),
|
||||||
|
};
|
||||||
|
|
||||||
JSValue js_nota_encode(JSContext *js, JSValue self, int argc, JSValue *argv)
|
JSValue js_nota_encode(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
if (argc < 1) return JS_UNDEFINED;
|
if (argc < 1) return JS_UNDEFINED;
|
||||||
|
@ -3659,6 +3716,7 @@ void ffi_load() {
|
||||||
QJSGLOBALCLASS(joint);
|
QJSGLOBALCLASS(joint);
|
||||||
QJSGLOBALCLASS(dspsound);
|
QJSGLOBALCLASS(dspsound);
|
||||||
QJSGLOBALCLASS(performance);
|
QJSGLOBALCLASS(performance);
|
||||||
|
QJSGLOBALCLASS(geometry);
|
||||||
|
|
||||||
QJSGLOBALCLASS(poly2d);
|
QJSGLOBALCLASS(poly2d);
|
||||||
|
|
||||||
|
@ -3698,6 +3756,8 @@ void ffi_load() {
|
||||||
array_proto = js_getpropstr(array_proto, "prototype");
|
array_proto = js_getpropstr(array_proto, "prototype");
|
||||||
JS_SetPropertyFunctionList(js, array_proto, js_array_funcs, countof(js_array_funcs));
|
JS_SetPropertyFunctionList(js, array_proto, js_array_funcs, countof(js_array_funcs));
|
||||||
|
|
||||||
|
srand(stm_now());
|
||||||
|
|
||||||
JS_FreeValue(js,globalThis);
|
JS_FreeValue(js,globalThis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#define PI 3.14159265
|
#define PI 3.14159265
|
||||||
|
|
||||||
int SAMPLERATE = 44100;
|
int SAMPLERATE = 48000;
|
||||||
int BUF_FRAMES = 2048;
|
int BUF_FRAMES = 2048;
|
||||||
int CHANNELS = 2;
|
int CHANNELS = 2;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue