From 9bbe880466b736ef9821c94bf3b081829bb2271c Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Fri, 27 Sep 2024 14:30:15 -0500 Subject: [PATCH] timers --- scripts/components.js | 2 +- scripts/render.js | 4 +++- source/engine/jsffi.c | 18 +++++++++++++++--- source/engine/timer.c | 5 +++++ source/engine/timer.h | 1 + 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/scripts/components.js b/scripts/components.js index 73c5af1..a9a69e9 100644 --- a/scripts/components.js +++ b/scripts/components.js @@ -75,7 +75,7 @@ var sprite = { // self?.anim_done?.(); // if (!self.loop) { self.stop(); return; } } - // if (self) stop = self.gameobject.delay(advance, playing.frames[f].time / self.anim_speed); + if (self) stop = self.gameobject.delay(advance, playing.frames[f].time / self.anim_speed); } advance(); diff --git a/scripts/render.js b/scripts/render.js index b1ea708..2738211 100644 --- a/scripts/render.js +++ b/scripts/render.js @@ -719,8 +719,9 @@ var img_idx = 0; function flush_img() { if (img_idx === 0) return; render.use_shader(spritessboshader); - render.use_mat({ diffuse: lasttex }); + //render.use_mat({ diffuse: lasttex }); render.make_sprite_ssbo(img_cache.slice(0, img_idx), poly_ssbo); + cur.images = [lasttex]; render.draw(shape.quad, poly_ssbo, img_idx); lasttex = undefined; img_idx = 0; @@ -761,6 +762,7 @@ render.image = function image(tex, pos, scale, rotation = 0, color = Color.white var e = img_e(); e.transform.trs(pos, undefined, scale); e.shade = color; + e.texture = tex; return; var bb = {}; diff --git a/source/engine/jsffi.c b/source/engine/jsffi.c index 2ddd05f..2ab850d 100644 --- a/source/engine/jsffi.c +++ b/source/engine/jsffi.c @@ -1107,17 +1107,29 @@ JSC_CCALL(render_make_sprite_ssbo, for (int i = 0; i < js_arrlen(array); i++) { JSValue sub = js_getpropidx(array,i); - ms[i].model = transform2mat(js2transform(js_getpropstr(sub, "transform"))); + transform *tr = js2transform(js_getpropstr(sub, "transform")); texture *t = js2texture(js_getpropstr(sub, "texture")); + HMM_Vec3 tscale; + if (t) { - HMM_Vec3 tscale; tscale.x = t->width; tscale.y = t->height; tscale.z = 1; - ms[i].model = HMM_MulM4(ms[i].model, HMM_Scale(tscale)); + tr->scale = HMM_MulV3(tr->scale, tscale); } + + tr->scale.x = 100; + tr->scale.y = 100; + tr->scale.z = 1; + tr->pos.x = 100; + tr->pos.y = 100; + tr->pos.z = 0; + ms[i].model = transform2mat(t); ms[i].rect = js2vec4(js_getpropstr(sub,"rect")); ms[i].shade = js2vec4(js_getpropstr(sub,"shade")); + + if (t) + tr->scale = HMM_DivV3(tr->scale, tscale); } sg_append_buffer(*b, (&(sg_range){ diff --git a/source/engine/timer.c b/source/engine/timer.c index ce0f77c..eff97e5 100644 --- a/source/engine/timer.c +++ b/source/engine/timer.c @@ -29,3 +29,8 @@ void timer_update(double dt) timers[i]->remain -= dt; } } + +void timer_stop(timer *t) +{ + +} \ No newline at end of file diff --git a/source/engine/timer.h b/source/engine/timer.h index b425b47..22e31a7 100644 --- a/source/engine/timer.h +++ b/source/engine/timer.h @@ -8,5 +8,6 @@ typedef struct timer { timer *timer_make(); void timer_free(timer *t); void timer_update(double dt); +void timer_stop(timer *t); #endif